@@TRANCOUNT

@@TRANCOUNT is a global system variable that count transaction’s command. Per a BEGIN TRAN or COMMIT|ROLLBACK TRAN it counts once.


begin tran Test_tran
select *
     into #temp1
     from Sales.OrderDetails ;
     select @@TRANCOUNT ;
commit tran
GO

select @@TRANCOUNT ;
GO

select *
     from #temp1 ;

note!
If we COMMIT a transaction it counts back to zero.
If it’s not zero means that a transaction block is uncompleted.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s