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.
Author |
Topic |
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2005-05-26 : 11:59:51
|
How to code to copy new records from tableA in remote server to tableB in local server? |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-05-26 : 12:22:24
|
assuming you have linked servers set up:insert into TableB (col1, col2)select t1.col1, t1.col2from server1.db1.ownername1.tableA t1left join server2.db2.ownername2.tableb t2 on t1.col1 = t2.col1where t2.col1 is nullGo with the flow & have fun! Else fight the flow |
 |
|
coolerbob
Aged Yak Warrior
841 Posts |
Posted - 2005-05-26 : 12:23:11
|
INSERT INTO TargetSELECT * FROM Source SWHERE NOT EXISTS (SELECT 'X' FROM Target TWHERE S.PK = T.PK) |
 |
|
coolerbob
Aged Yak Warrior
841 Posts |
Posted - 2005-05-26 : 12:23:41
|
you're too quick spirit1/** sql sui generis **/ |
 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2005-05-26 : 12:37:29
|
Thank you. I'll try both ways. If I want to copy more than one tables, how to code? |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-05-26 : 12:38:28
|
one insert for each table.Go with the flow & have fun! Else fight the flow |
 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2005-05-27 : 10:06:41
|
I test them but I do not which way is fast since I only test about 100 records. |
 |
|
|
|
|