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 2005 Forums
 Transact-SQL (2005)
 create query across 2 seperate databases

Author  Topic 

rbohaty
Yak Posting Veteran

71 Posts

Posted - 2007-11-11 : 14:10:21
I have 2 databases on one server named Backup & Production. Both have a table called names.

How do I query across the 2 db's? This is SQL 7.0 Sp4.

Thanx

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-11 : 14:12:43
Use the full name ( database.dbo.tablename)

Select a.[Column], b.[Column]
FROM [Backup].dbo.[Names] a inner join [Production].dbo.[Names] on a.[LinkingField] = b.[LinkingField]
Go to Top of Page

rbohaty
Yak Posting Veteran

71 Posts

Posted - 2007-11-11 : 16:29:14
perfect!! I had my suntax messed up as usual
Go to Top of Page
   

- Advertisement -