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)
 Joining Two tables from two different connection

Author  Topic 

c.vaibhav
Starting Member

26 Posts

Posted - 2009-10-24 : 03:48:52
Hi,
I have two SQL tables present in two different databases. Can I apply a join to these two tables situated in two separate database and different connections as well.

Regards,
Vaibhav

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-24 : 04:54:17
yup. you can. if they're in same server you can just use

select columns...
from db1..table1o one
join db2..table2
...



and if they're on different server, you need to set up linked server connection to one from other using sp_addlinkedserver sp and then use like

select columns...
from db1..table1o one
join server2.db2..table2
...
Go to Top of Page
   

- Advertisement -