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-10-12 : 12:55:47
|
| I have two tables of data. One table is used for backup and is cleared and uploaded weekly, then used to compare against the primary table. What I would like to do is run a stored procedure that has the backup table insert records into the primary table if they are not already there.The field I would check is Account so I would tell it to insert into the table where Account does not exist. I think this would use the "Not In" or "Exists" functions. Thanks |
|
|
SreenivasBora
Posting Yak Master
164 Posts |
Posted - 2005-10-12 : 15:55:50
|
| If you filter data only on "Account" column then use "NOT in"Multiple columns join then use Exists.See books online for more help.With RegardsBSR |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-10-12 : 17:38:44
|
| How about a LEFT JOIN instead?INSERT INTO primarytableSELECT ... FROM backuptable bLEFT JOIN primarytable p on b.AccountKey = p.AccountKeyWHERE p.AccountKey IS NULL---------------------------EmeraldCityDomains.com |
 |
|
|
|
|
|