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)
 access multiple databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-11 : 09:23:20
surjit writes "How can i retrieve data from different tables that are again in different databases.
Suppose i hava two databases D1, D2
D1 has one table T1
and D2 has one table T2
i want to write a query to access data from T1 and T2."

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-04-11 : 09:27:38
you can use a DTS packages that can access tables from different database, and put them into one of the 2 databases so they are on a single Database. Are you using SQL 2000?

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-11 : 09:49:10
If you are in D1, then

Select * from T1
Select * from D2.dbo.T2


Madhivanan

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

Kristen
Test

22859 Posts

Posted - 2006-04-11 : 09:56:13
... or possibly even:
[code]
Select *
from T1
JOIN D2.dbo.T2
ON T2.MyPK = T1.MyPK
[code]
Kristen
Go to Top of Page
   

- Advertisement -