Reputation: 1
How can I select data in the same query from two different databases that are on two different servers, one DB2 Server and the other a SQL Server?
Upvotes: 0
Views: 1402
Reputation: 18759
You can set up a linked server http://support.microsoft.com/kb/222937
Upvotes: 1
Reputation: 20804
On your sql server, set up a linked server to the db2 database.
Then write your query on sql server. I suggest that you use openquery for the db2 stuff. If you have to combine the data, populate a sql server temp table with the openquery results and work from there.
The reason I suggest this is performance. I have found that if you use this syntax
select somefields
from server.database.owner.table
where whatever
sql server will bring back the entire table from the linked server and apply the where clause afterwards.
Upvotes: 1