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
 Transact-SQL (2000)
 Query different tables in different databases

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-06-03 : 23:49:22
I need to query different tables in different databases and they lie on the same server.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-06-03 : 23:52:15
you can reference the tables as follows:
databasename.owner.tablename.

see example below.......

select a.id, a.desc, b.salesvalue
from db1.dbo.item a
join db2.dbo.sales b
on a.id = b.id


Duane.
Go to Top of Page
   

- Advertisement -