I need to be able to connect to 3 remote databases simultaneously from my local SQL Server instance using SQL Server 2008 R2. Db1 and Db2 are both on Svr1 and Db3 is on Svr3. Each database requires a different login to gain access. I want to write a script that has simultaneous access to all 3 databases.
I gave up trying to create these using sp_addlinked server (despite successful use of this in past projects) because I simply could not get any of the connections working. I did manage to set up working linked servers for access to Db1 and Db3 on Svr1 and Svr3 respectively, no problem, using SSMS (right click on Linked Servers, New Linked Server). However, I don't know how to set up the linked server for db2 - it will not allow me to set up 2 linked servers with the same name (understandably). When I try to set up one using a name that does not map to a known SQL Server instance (and so use a data source or provider string to connect), it won't work.
Can I do what I want to do using the SSMS method? Or is there a way I can use the same linked server for Db1 and Db2 but use different logins somehow?
Related
I have set up 2 separate Database Engine connections in SSMS 2017. One connection is to the company server databases and the other is for my local database instance. Now, when I open SQL files with code referring to the Server Instance (#1), it fails to run because it doesn't recognize the tables or the attributes. I have to right click on the Server Name in the Object Explorer and open A New Query page, copy the code from the SQL file and paste it onto the new Query page and then run it.
How do I get the SQL file to run by opening it and clicking on Execute?
If you are trying to reach a different database instance from your local hosted instance, you will need to create a linked server.
Once you have that in place you can mix the database connections from a single sql file by using 4 part naming conventions [Server].[Database].[Schema].[Table].
We have a lot of linked servers in our SQL Server 2012 instances. While browsing one of those linked servers, I noticed that a log-shipped database is unavailable there.
The database itself is "Standby / Read-Only."
Is it normal for log-shipped databases to be unavailable over linked servers, or is it more likely to be a permissions issue, or could it be something else? I want to query this database using a linked server query.
The cause of my problem is obviously a permission configuration with the linked server entry. I know this because I set up the same linked server on my local SQL Server instance--using my own login credentials--and was able to see the "Standby / Read-Only" database as I would've normally expected for a standard database. Clearly, then, there is something about the linked server setup on the other server that is restricting me from viewing one of the databases.
I am trying to run this query from an instance on premise to the Master database in Azure.
I can query the other database on the Azure instance with my linked server so that is working and the query I'm trying to run, runs when I log onto the Azure instance.
I just cannot get it to run from my server that has a linked server object set up for Azure.
The code I have tried is:
SELECT [database_id],[name],[Compatibility_level],[collation_name],[state_desc]
,[recovery_model_Desc],[is_broker_enabled],[is_cdc_enabled]
FROM [LinkedServerName].[Master].[sys].[databases]
I have also tried it this way:
EXEC ( 'SELECT [database_id],[name],[Compatibility_level],[collation_name],[state_desc] ,[recovery_model_Desc],[is_broker_enabled],[is_cdc_enabled]
FROM [Master].[sys].[databases]') AT [LinkedServerName]
Again with no success. I am getting this error:
Msg 40515, Level 16, State 2, Line 9
Reference to database and/or server name in 'Master.sys.sp_tables_info_90_rowset_64' is not supported in this version of SQL Server.
Any ideas to help me get around this?
When you created the linked server you specified the user database as the “Catalog” database, you did not specified the master database as the catalog (the database used for the linked server). That is the reason you are using cross database queries, and cross database queries using three and four-part names are not supported on Azure SQL Database as explained here.
Additionally not all sys tables are supported on Azure SQL Database. You will find some DMVs available on Azure SQL Database that do not exist on SQL Server on-premises and vice versa.
My scenario:
Access 2013 FE > SQL Server 2012 BE > Linked Server To IBM DB2
The FE Needs to be used by multiple people. I'm calling SP's in SQL Server that update the IBM DB2. The only easy way for Access to talk directly to the IBM is to install 'Client Access' on each client, which I don't really want to do, hence I use SQL Server and a DSN Less connection as the bridge.
My Problem:
The front end involves user selecting multiple items, adding them to a SQL Server table and then a SP runs that in turn updates the IBM DB2. However, if multiple users are using the FE, then they will all be adding multiple items to the one table, which I don't want, it needs to be session\client specific.
Is there a way round this?
the issue:
We have a Db named for example 'DBUni' and 4 SQL servers In various cities
Server1 is connected to Server 2
Server2 is connected to Server 1,3
Server3 is connected to Server 2,4
Server4 is connected to server 3
Problem: We have to have a SQL Connection from Server 4 to Server 1
Right now 'DBUni' is on Server1 and it is Linked To Server2 through SQL Server Link Servers
Does anyone have a solution?
You could create a view on the linked server referring to the other linked servers, this could become an extensive list of views though.
The view would not be restricted to only the same server, since it can refer to a different linked server. This way you could make a hierarchy of views. I have no idea how this would affect performance though.