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)
 Inner Join across 2 databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-16 : 10:09:10
Jacqui writes "Is it possible to do an inner join across 2 databases that are sitting on the same SQL server (SQL 7.0). The one table(A) holds a foreign key to a table in another database (B). I can not change the DB design.

What is the syntax?? ... I have tried using dbname.tablename with no luck.

Thanks."

Nazim
A custom title

1408 Posts

Posted - 2002-04-16 : 10:14:31
a little forum search could have saved you.

Anywayz , follow the four part naming convention.
Servername.databasename.owner.objectname

select t1.columnames from onedatabase..tablename t1
on anotherdatabase..tablename t2
on t1.commonkey=t2.commonkey

HTH

--------------------------------------------------------------
Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-04-16 : 10:16:02
Please read this FAQ entry at my site: http://vyaskn.tripod.com/programming_faq.htm#q13

You basically have to prefix the table name with database.owner

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page
   

- Advertisement -