cancel
Showing results for 
Search instead for 
Did you mean: 

What low severity errors let transactions complete even though a statement didn't execute

09-30-2026 11:51 PM
sladebe Active Participant
136 views 4 comments Go to solution
0 Likes
Subscribe

Given a transaction batch like this:

begin transaction
insert into mytable (id) values (1)
insert into mytable (id) values (2) -- error occurs here
insert into mytable (id) values (3) 
commit transaction

I'm pretty sure there are some low severity errors where, if they occur in the 2nd insert, the transaction will complete (commit) but with the row with id=2 missing (not inserted)

My question is, where is the documentation for this error severity transaction interaction?  

Thanks in advance
Ben

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

sladebe
Active Participant
0 Likes

I also found this web page

Transact-SQL Users Guide -> Transactions: Maintain Data Consistency and Recovery -> Transactions in Stored Procedures and Triggers -> Errors and Transaction Rollbacks

which says (square brackets are my annotation):

Errors in data modification commands that affect data integrity [where a statement fails but doesn't abort the transaction] :

  • Arithmetic overflow and divide-by-zero errors (effects on transactions can be changed with the set arithabort arith_overflow command)
  • Permissions violations
  • Rules violations
  • Duplicate key violations

Granted, this is in a "Stored Procedures and Triggers" section, but I think it applies to transactions outside of stored procs and transactions too.

But, the behavior is slightly different in a trigger!  From the same web page:

With duplicate key errors and rules violations, the trigger completes (unless there is also a return statement), and statements such as print, raiserror, or remote procedure calls are performed. Then, the trigger and the rest of the transaction are rolled back, and the rest of the batch is aborted.

Answers (0)