Check the Transaction State with @@transtate

@@transtate contains the current state of a transaction after a statement executes in the current user session. Unlike @@error, @@transtate is not cleared for each batch.

@@transtate may contain the values in this table:

Value

Meaning

0

Transaction in progress: an explicit or implicit transaction is in effect; the previous statement executed successfully.

1

Transaction succeeded: the transaction completed and committed its changes.

2

Statement aborted: the previous statement was aborted; no effect on the transaction.

3

Transaction aborted: the transaction aborted and rolled back any changes.

@@transtate changes only due to execution errors. Syntax and compile errors do not affect the value of @@transtate.

Related concepts
Transaction States