You probably know how to insert records into a table using single or multiple VALUES clauses. You also know how to do bulk inserts using SQL INSERT INTO SELECT. But you still clicked the article. Is it about handling duplicates?

Many articles cover SQL INSERT INTO SELECT. Google or Bing it and pick the headline you like best – it will do. I won’t cover basic examples of how it is done either. Instead, you will see examples of how to use it AND handle duplicates at the same time. So, you can make this familiar message out of your INSERT efforts:

Msg 2601, Level 14, State 1, Line 14
Cannot insert duplicate key row in object 'dbo.Table1' with unique index 'UIX_Table1_Key1'. The duplicate key value is (value1).

But first things first.

#sql server #sql functions #sql

SQL INSERT INTO SELECT: 5 Easy Ways to Handle Duplicates
1.05 GEEK