Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query across two servers

Author  Topic 

texas1992
Starting Member

21 Posts

Posted - 2012-10-25 : 09:56:31
I have a query that I need to make that will cross two servers.

Select a.Field1, b.Field2
From tableA a Left Join tableB b ON a.id = b.id

tableA resides on server1 and tableB resides on server2.

How do I do this?

Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-25 : 10:12:20
you've add one server as a linked server to other and then use four part naming convention like Server.DB.Schema.Table

see

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=164892

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

texas1992
Starting Member

21 Posts

Posted - 2012-10-25 : 14:12:54
Thanks. I just haven't done this for a long time and forgot.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-25 : 14:59:03
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -