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 2005 Forums
 Transact-SQL (2005)
 select from two different servers

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2007-10-23 : 13:12:04
I have a server named pivotaldb and another server named crmtest.
From the pivotaldb server, I want to write a select statement which references a database on the crmtest. Can this be done?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-10-23 : 16:06:12
Check out Linked Servers in Book Online.
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-10-23 : 17:45:53
Once you link the server it is pretty easy..

Select Table1.ColumnName, Table2.COlumnName
From pivotaldb.[Database].dbo.[Table1] Table1 inner join crmtest.[Database].dbo.[Table2] Table2 on Table1.LinkColumn = Table2.LinkColumn

For example...
Go to Top of Page
   

- Advertisement -