Linking SQL Server databases to create DTS packages

Tags:
Business Intelligence
DTS
SQL Server
I want to create a DTS package in SQL Server for the following problem: 1. Table T1 in Database DB1 in server1. 2. Table T2 in Database DB2 in server2. 3. Table T3 in Database DB3 in server3. The DTS package will be created in DB3. I need to copy data from T1 and T2 based on T1.ID = T2.ID, from the two servers to DB3. How can I link the two databases? I tried sp_addlinkedserver, but it didn’t work. What SQL (distributed) query can be use? I’d be grateful if you could narrate an example to follow.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You’ve got a couple of options here.

1. On server1 create a linked server to server2 using the sp_addlinkedserver procedure. Then use a query from server1 to join the two tables together (using what ever columns are needed).
<pre>SELECT T1.*
FROM DB1.dbo.T1 T1
INNER JOIN SERVER2.DB2.dbo.T2 T2 ON T1.ID = T2.ID</pre>

2. Setup working tables in the DB3 database and load all the records from T1 and T2 into these tables then use a normal T/SQL insert statement to get the needed data into table T3.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following