My TRANSACTION Notes

XACT_STATE() 

https://docs.microsoft.com/en-us/sql/t-sql/functions/xact-state-transact-sql?view=sql-server-ver15

0 = no active transaction

1 = active transaction

-1 =  active transaction but your only option is ROLLBACK (it's doomed)


@@TRANCOUNT

BEGIN TRANSACTION increments by 1

COMMIT TRANSACTION decrements by 1

ROLLBACK TRANSACTION sets to zero (except when using SAVEPOINT)


SET XACT_ABORT { ON | OFF }

ON = error causes transaction to ROLLBACK

 

Paul Randal:

Open Transactions with Script and Plan

Comments

Popular posts from this blog

Using sp_executesql with OPENQUERY

Executing Remote Queries Safely and Efficiently with sp_executesql