Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Studio Management - How to run queries across multiple servers

My 2 server both use SQL Server 2008 R2

I have my local SQL server and also an Amazon machine running an instance of SQL-Server there.

I'm able to connect from my local machine to that Amazon SQL using the standard 10.10.10.10, 1433 connection from my local Management Studio.

What i need to do now is to run a query that says ..tells me what records I have locally that are not on the Amazon server right now.

Something like:

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

================================ Question:
I don't know how to write the "AMAZON" location on the Query window itself, since it's running on a different server.

Any help is truly appreciated !!!

like image 822
SF Developer Avatar asked Aug 06 '12 06:08

SF Developer


1 Answers

You have to configure AMAZON Server as LINKED Server on your local machine. If you name it "AMAZON" - you query will work exactly as you wrote.

like image 128
Andrei Rantsevich Avatar answered Nov 28 '22 12:11

Andrei Rantsevich