TSQL joining tables on different servers

vivekj2004
vivekj2004 used Ask the Experts™
on
Can we join 2 tables on two different servers on 2 different databases?
These 2 databases need 2 different connectionStrings for connection.
Comment
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..

Author

Commented:
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:
http://www.quackit.com/sql_server/sql_server_2008/tutorial/linked_servers.cfm

These are guides for creating linked servers:
http://www.hitsw.com/support/kbase/sql_servers/OLEDB_1622_SQLSrv2005.htm

http://www.sqlservercentral.com/Forums/Topic574262-146-1.aspx

Hope it helps.

Author

Commented:
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