Groups | Blog | Home
all groups > sql server new users > october 2005 >

sql server new users : comparing data across different servers


Donna Mak
10/11/2005 11:11:59 PM
Hi,

I have 2 tables with identical schema on 2 different servers; with one table
containing the most up-to-date data and another containing one day behind
data. I want to compare these tables and insert the changes into a table
(also identical schema) on a third server. How can I achieve this on sql
server 2000?

Thanks.

Donna

Jens
10/11/2005 11:24:49 PM

Here is some pseudocode that you have to adapt

INSERT INTO SomeNeTableonthethirdServer
SELECT * from TheNewdataTable
Where ID_from_the_table NOT IN
(
Select ID_from_the_table from TheNewdataTable t1
inner join TheOlddataTable t2
on t1.Col1_to_compare = t2.Col1_to_compare
<...every colum you want to compare if its changed>
)


HTH, Jens Suessmeyer
Donna Mak
10/12/2005 9:29:32 PM
Thanks. But in order to get this to work, I have to use linked servers,
correct? and where should I store this query?

--Donna

[quoted text, click to view]

Jens
10/12/2005 11:18:02 PM
Yes linked servers sounds good to me :-D. I would store it on the
server where you are doing the insert.

HTH, Jens Suessmeyer.
AddThis Social Bookmark Button