I have 2 Identical tables in SQL Server 2008, one is the “Live” table which my application is constantly using. I am pulling down new records periodically during the day and inserting them into a “staging” table from which I need to pull new records and insert into the Live table. I don’t want any duplicates inserted just in case some records are overlapped. There are 10 columns which I need to look at to see if an identical record exists, I have looked at some TSQL examples but none so far are working, I have also considered dealing with the dupes and just reporting on the DISTINCT values but DISTINCT one works for one record, I need it to work for 10. Any suggestions?
Thanks,
Sam
This is an ideal use case for
NOT EXISTS– you can check on as many criteria as you like to verify you won’t insert a dupe.