Copy link to clipboard
Copied
Hi,
I have two tables T1 and T2 of same structure at two different sql servers.T1 has 1,00,000 records and T2 has 99,000 records. Is it possible to copy
the extra records(1000 records) from table T1 to T2 which are not present in T2. Read about linked server. Is there any other alternative ways?
Thanks
Copy link to clipboard
Copied
An idea comes to mind immediately. Backup your tables before you do anything. Then, whatever happens, you will be able to return them to their original state.
The idea goes as follows. Copy T1 to the server that has T2. On this server, do the following
INSERT INTO T2
SELECT T1.*
FROM T1
WHERE T1.PKCol NOT IN
(SELECT T2.PKCol
FROM T2)
The idea is straightforward. You use the primary key to get the 1000 records that are in T1 but not in T2, and insert them in T2.