@@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 ;
If we COMMIT a transaction it counts back to zero.
If it’s not zero means that a transaction block is uncompleted.