Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I join tables across servers? 1

Status
Not open for further replies.

partridge80

Technical User
Nov 26, 2002
12
GB
Can anyone give me an overview of this please?
 
You must link the remote servers to your server.
YourServer -> Security -> Linked Servers

then just do a

select a.*, b.* from Server1.myDatabase.dbo.Table1 as a, MyServer.AnotherDb.dbo.Table2 as b ON a.MyID = b.MyID
 
The easiest way is to set up linked servers.

eg, set server2 up as a linked server in server1 and then execute this type of query on server1:

Code:
SELECT * FROM table1 t1 JOIN server2.dbname.owner.table2 t2 ON t1.idcol = t2.idcol

Note how you just need to use the 4-part qualified name. You can find more information in BOL - look up "linked servers". --James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top