Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select query between 2 databases

Status
Not open for further replies.

tamnguyen

MIS
Nov 23, 2005
2
CA
How to select a union query between 2 tables from 2 separate databases. Thank you.
 
Do the two databases reside on the same server?
 
The 2 servers need to be linked or registered. Then all you need to do is fully qualify the tables in the select statement

Select * from [ServerA].[DatabaseA].[dbo].[TableA] A join
[ServerB].[DatabaseB].[dbo].[TableB] B on
A.PrimaryKetID = B.ForeignKeyID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top