SQL - Structured Query Language |
@@TRANCOUNT@@TRANCOUNT is used to returns the number of BEGIN Transaction statements that have occurred on the current database connection. BEGIN and COMMIT Example The following example displays the effect that nested BEGIN and COMMIT statements have on the @@TRANCOUNT variable. --
Example 70 -- USE EBusiness GO PRINT @@TRANCOUNT
-- The result is 0 BEGIN TRAN --Increment variable value 1 from existing value 0
PRINT @@TRANCOUNT -- The
result is 1
BEGIN TRAN -- Increment variable
value 1 from existing value 1
PRINT
@@TRANCOUNT -- The
result is 2
COMMIT -- Decrement variable value 1 from existing value 2
PRINT @@TRANCOUNT -- The
result is 1 COMMIT -- Decrement
variable value 1 from existing value 1 PRINT @@TRANCOUNT
-- The result is 0 --
Example 71 -- USE EBusiness GO PRINT @@TRANCOUNT
-- The result is 0 BEGIN TRAN -- Increment variable value 1 from existing value 0
PRINT @@TRANCOUNT -- The result is 1
BEGIN TRAN -- Increment variable
value 1 from existing value 1
PRINT
@@TRANCOUNT -- The
result is 2 ROLLBACK -- Clear variable
value and stores 0 PRINT @@TRANCOUNT
-- The result is 0 |
* * * * *