user2478694
user2478694

Reputation: 1

How can I select data in the same query from two different servers and databases from SQL Server Management Studio?

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

Answers (2)

Christian Phillips
Christian Phillips

Reputation: 18759

You can set up a linked server http://support.microsoft.com/kb/222937

How to create a linked server

Upvotes: 1

Dan Bracuk
Dan Bracuk

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

Related Questions