views:

869

answers:

4

Hi Everyone,

I wanna learn how to join two tables which are located two different SQL Server instances.

Thanks in advance.

+5  A: 

You can create a linked server and reference the table in the other instance using its fully qualified Server.Catalog.Schema.Table name.

Jason Punyon
+2  A: 

If you are using SQL Server try Linked Server

rdkleine
+1  A: 

I think you'll find the information you need here.

Stuart Thompson
+2  A: 

The best way I can think of to accomplish this is via sp_addlinkedserver. You need to make sure that whatever account you use to add the link (via sp_addlinkedsrvlogin) has permissions to the table you're joining, but then once the link is established, you can call the server by name, i.e.:

SELECT *
FROM server1table
    INNER JOIN server2.database.dbo.server2table ON .....
Scott Anderson