Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

@@TRANCOUNT - TRANCOUNT Function

Posted By: Sarita Patel     Category: SQL Server     Views: 3477

This article explains about @@TRANCOUNT function in sql server with examples.

@@TRANCOUNT function returns the number of active transactions for the current connection.

The BEGIN TRANSACTION statement increments @@TRANCOUNT by 1. ROLLBACK TRANSACTION decrements @@TRANCOUNT to 0, except for ROLLBACK TRANSACTION savepoint_name, which does not affect @@TRANCOUNT. COMMIT TRANSACTION or COMMIT WORK decrement @@TRANCOUNT by 1.


Syntax of @@TRANCOUNT Function :

@@TRANCOUNT

Return type of @@TRANCOUNT function is an integer.




Examples of @@TRANCOUNT Function :

Example 1 : Use of @@TRANCOUNT function in select clause 

SELECT @@TRANCOUNT

Output
0

Above example returns 0 means currently there is no active transaction for the current connection.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on @@TRANCOUNT - TRANCOUNT Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of @@TRANCOUNT - TRANCOUNT Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!