Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 joining tables from two servers

Author  Topic 

macsterling
Yak Posting Veteran

56 Posts

Posted - 2010-06-10 : 16:51:06
We have an application that extracts data from DB1 on \\server1 and after lots of number crunching, puts it in DB2 on \\server2. Now we are trying to reconcile everything and find that there are a some "extra" rows on DB2. One of the tables has over 600,000 rows, so "looking" for them is not an option. How do I connect the two so that I can do an outer join and find the additional rows?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-06-10 : 17:16:47
You can create a linked server and use the 4-part server name in the query..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-06-10 : 17:47:30
Since you have relatively small tables you'll probably be ok. But, be aware that joining tables across linked servers can be VERY costly/slow.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-06-10 : 17:50:48
Personally even for medium sized tables I'd pull the data locally into a temporary table and then JOIN to compare. Chances are you will try-this then try-that and if each one is 10x slower than local it will become a nuisance, even if only a few seconds each time.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-06-11 : 11:26:09
Agree with the performance part.. it might be faster to use SSIS or BCP to pull the date into a temporary/staging table on the other server and then join locally... and perhaps purge the table when done..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -