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)
 Query against 2 different databases....

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-04 : 22:26:21
paleDecay writes "i got this tiny problem...
i need to be able to query data between 2 seperate databases...

let me draw a lil picture.. or try =)


Microsoft SQL Server
-SQL Server Group
-SQL1 ( Windows NT )
-Databases
-Database1
>DB1_Table1
>DB1_Table2
-Database2
>DB2_Table1
>DB2_Table2



ok, i want to query againt DB2_Table1 and DB1_Table1.
i just need to know HOW to make it be able to select from the 2 seperate databases... i'm tryin to write this in VB..

i have thought about creating a temporary table in Database2 that has the current data of DB1_Table1, but i want to do that programmatically too.. and i am having some problems...

any help is appreciated,

Thanks in advance,
-paleDecay"

chadmat
The Chadinator

1974 Posts

Posted - 2002-03-04 : 22:31:27
Just use the full 4 part name (Or at least the last 3 parts)

ex:

select * from Database1.dbo.DB_Table1 d1
INNER JOIN Database2.dbo.DB_Table1 d2
ON d1.ID = d2.ID

etc...

-Chad

Go to Top of Page
   

- Advertisement -