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 |
|
oahu9872
Posting Yak Master
112 Posts |
Posted - 2005-09-22 : 16:22:06
|
| I need to write a stored procedure that would compare 2 tables by taking the first table and copying all of the records into the second table that do not exist there. For example...Table APerson 1Person 2 Person 3Table BPerson 1After the stored procedure ...Table BPerson 1Person 2Person 3Any records in A that are not in B are inserted into B. I've used the EXISTS function for things similar this to delete and update, but i'm not sure how it works for inserting. Thanks. |
|
|
ronstone
Starting Member
32 Posts |
Posted - 2005-09-22 : 16:32:20
|
| I think you would use left join with your insert where the columns in table b you are comparing are null |
 |
|
|
ronstone
Starting Member
32 Posts |
Posted - 2005-09-22 : 16:35:58
|
| INSERT INTO TableBSELECT TableA.NameFROM TableALEFT JOIN TableB ON (TableA.Name = TableB.Name)WHERE TableB.Name IS NULL |
 |
|
|
|
|
|