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 transactionI'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
Request clarification before answering.
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] :
|
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. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.