Some global variables provide information to use in transactions.
Check for Errors with @@error
The @@error global variable is commonly used to check the error status of the most recently executed batch in the current user session. @@error contains 0 if the last transaction succeeded; otherwise, @@error contains the last error number generated by the system.
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.