Checking the transaction nesting level with @@trancount

@@trancount contains the nesting level of transactions in the current user session. Each begin transaction in a batch increments the transaction count. When you query @@trancount in chained transaction mode, its value is never 0 because the query automatically initiates a transaction.