Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm new to SQL, so need a little help. I have to join two tables which are in two different databases which are on different servers. Can someone please tell me how can I do that?

share|improve this question

1 Answer 1

You sure can, as long as you have permission to access the tables on the other server. Just qualify the table names with the server name, database name, and schema name, like so:

SELECT * FROM otherserver.testdb.dbo.MyTable

You'll have to first set up the remote server as a "linked server" - you should be able to find plenty of guides for doing that with a little Google searching, or just pester your local DBA. It's pretty easy when connecting two SQL Server systems, but Kerberos can be a little fussy if you want to impersonate Windows credentials.

share|improve this answer
    
Thanks for the answer –  sharepoint99 Mar 29 '11 at 2:27
1  
@sharepoint99 If you feel this answer sufficiently resolves your problem, you should accept it as the answer (there should be a checkmark on the left side you can click). –  bhamby Mar 29 '11 at 20:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.