How to Direct the DBMS to Roll Back an Entire Transaction or Statement
To direct the DBMS to roll back an entire transaction (or a single statement), use the SET SESSION WITH ON ERROR = ROLLBACK STATEMENT | TRANSACTION statement.
Note: The errors Deadlock, Transaction Log Full, and Lock Quota Exceeded always roll back the entire transaction regardless of the current ON_ERROR setting.