Articles → SQL SERVER → @@Transactioncount In SQL Server

@@Transactioncount In SQL Server






Purpose





Impact Of Commit And Rollback On "@@Transactioncount"





Example


PRINT @@TRANCOUNT -- Count  = 1
BEGIN TRAN -- Set @@TransactionCount = 2
PRINT @@TRANCOUNT BEGIN TRAN -- Set @@TransactionCount = 3 
Rollback -- Resets @@TransactionCount to zero
PRINT @@TRANCOUNT BEGIN TRAN -- Set @@TransactionCount = 1 
BEGIN TRAN -- Set @@TransactionCount = 2
COMMIT -- Reduces @@TransactionCount  to 1
PRINT @@TRANCOUNT BEGIN TRAN -- Set @@TransactionCount = 2
COMMIT -- Reduces @@TransactionCount  to 1
PRINT @@TRANCOUNT



Output


Picture showing the output of @@TransactionCount in SQL server



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, October 5, 2017

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250