TSQL joining tables on different servers

vivekj2004 used Ask the Experts™
Can we join 2 tables on two different servers on 2 different databases?
These 2 databases need 2 different connectionStrings for connection.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you're joining them on a query, then yes.
You'd need a linked server to Server2 and then you can query all the tables in Server2 as follows:

Select * from Server2.myDataBase.owner.myTable

And you can use it to join the tables as well..


what is this linked server. Can I get some sample code or screen-shots (even some link will do), that is good for explaining this.
A linked server allows you to query another SQL Server that is running in a different computer/server then the one you're working on.

Maybe this can give you a hint:

These are guides for creating linked servers:


Hope it helps.


Links can be accessed by me also. I was looking for some personal examples, describing remote servers names, how to install drivers and so on.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial