How to Ignore “Duplicate Key” error in T-SQL (SQL Server)

后端 未结 12 670
故里飘歌
故里飘歌 2020-12-02 18:12

I have a transaction that contains multiple SQL Statements (INSERT, UPDATE and/or DELETES). When executing, I want to ignore Duplicate Error statements and continue onto the

12条回答
  •  甜味超标
    2020-12-02 18:46

    I'd like to chime in with the following:

    If 99% of your data is going to insert without error doing a select beforehand results in a huge performance drop (like, in my case, from 200 lines/sec to 20 lines/sec) compared to "dumb" inserts and catching the occasional error.

    After ignoring the "Violation of PRIMARY KEY constraint" errors things went back to being bottlenecked by other resources (headroom being defined as "what the bottlenecking resources don't have").

    Which is the whole reason I landed on this discussion in the first place.

提交回复
热议问题