SQL Studio Management - Querying on Multiple Servers

My server 2 uses SQL Server 2008 R2

I have a local SQL server, as well as an Amazon machine that is running an instance of SQL-Server.

I can connect from my local machine to this Amazon SQL using the standard connection 10.10.10.10, 1433 from my local Management Studio.

Now I need to fulfill the request, which says: "Allows me to record those records that I have locally that are not currently on the Amazon server.

Sort of:

  SELECT * FROM [LOCAL].dbo.Table1 WHERE Field1 NOT IN (SELECT Field1 FROM [AMAZON].Database1.dbo.Table1) 

================================== Question:
I do not know how to write "AMAZON" in the Query window itself, since it works on another server.

Any help really appreciated !!!

+4
source share
4 answers

You need to configure AMAZON Server as LINKED Server on your local computer. If you call it "AMAZON", the request will work exactly as you wrote.

+3
source

In SSMS, \ Server Objects \ Linked Servers. Right-click the "new linked server". Name your server and select the "SQL server" radio button. Since I was an authorized user on both machines with Windows credentials, I selected the "Made with the current security context switch" radio button under the security tab and did not even have to fool local / remote user associations.

+2
source

In order to be able to run requests on multiprocessor servers, a link (linked server) must be established between the two servers. To create a linked server,

  • Go to the Linked Server subfolder in the Server Object folder
  • Right-click the Linked Server folder
  • Click "New Linked Server"
  • Put connection strings for the server
  • Name your linked server.

Now you can use the full qualification of the object (LinkedServer.Database.tableOwner.Table) to access the objects.

Good luck

+1
source

You must open the registered server window and create a group for your servers. then right-click the group name and select a new query (or select several servers in this group). if you run the request, it will be launched with the selected servers.

0
source

All Articles