SQL Join statement across two databases?
November 20, 2009 - 8:45 pm
Is there a way to create a join statement across two databases?
Using the example below..
I need to the specid column from System.dbo.PayerSpec and Data.dbo.claim
Can someone help me with this?
Thanks!
As long as both databases are part of the same SQL Server instance you can do it with a simple join.
select *
from system.dbo.PayerSpec p
inner join Data.dbo.claim c
on p.specid = c.specid
If they’re in different instances or on different servers, you want to look at setting up a linked server which lets you query between remote databases.
November 21st, 2009 at 2:30 am
select A.*, B.* from
System.dbo.PayerSpec A, Data.dbo.claim B
Where <…>
References :
November 21st, 2009 at 2:55 am
As long as both databases are part of the same SQL Server instance you can do it with a simple join.
select *
from system.dbo.PayerSpec p
inner join Data.dbo.claim c
on p.specid = c.specid
If they’re in different instances or on different servers, you want to look at setting up a linked server which lets you query between remote databases.
References :