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 2000 Forums
 SQL Server Development (2000)
 how to refer table from another database

Author  Topic 

wanni
Starting Member

14 Posts

Posted - 2006-06-02 : 22:02:19
I have two database, db1 and db2,

I can only make one connectino to sql server,

how do I get data from both db1 and db2 in 1 sql query ?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-03 : 00:17:14
[code]select *
from db1.dbo.tb1 t1 inner join db2.dbo.tb2 t2
on t1.col1 = t2.col2[/code]


KH

Go to Top of Page

wanni
Starting Member

14 Posts

Posted - 2006-06-03 : 06:33:00
quote:
Originally posted by khtan

select *
from db1.dbo.tb1 t1 inner join db2.dbo.tb2 t2
on t1.col1 = t2.col2



KH




thanks !!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 04:17:57
Provided that they are in the same Server. If DBs reside in other Server, you need to make use of Linked Server

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -