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 |
|
CSharpNewbie
Starting Member
39 Posts |
Posted - 2009-07-06 : 22:57:28
|
| Hi, I am creating a stored proc that compares the ID column in table A, with the ID column in table B, and then adds any missing records in table B to make both tables the same.I need help with the query.Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-06 : 23:00:27
|
[code]insert into tableb (ID)select a.IDfrom tablea awhere not exists (select * from tableb x where x.ID = a.ID)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 12:49:31
|
alsoinsert into tableb (ID)select a.IDfrom tablea awhere a.ID not in (select x.ID from tableb x )insert into tableb (ID)select a.IDfrom tablea aleft join tableb xon a.ID =x.ID where x.ID is null |
 |
|
|
|
|
|