dcsimg
 

SQL Server - INSERT and ignore on duplicate key

Thursday Apr 15th 2021 by Octavia Andreea Anghel
Article Image

How to insert values and ignore duplicate key errors in SQL Server.

Inserting values and ignoring duplicate key errors (or, other errors) can be done like this:

BEGIN TRY
INSERT INTO foo_table (...) VALUES (...)
...
END TRY
BEGIN CATCH
END CATCH
Home
Mobile Site | Full Site