[Solved] Is There any difference between rowcount and trancount [closed]


@@RowCount returns the Number of Rows affected by the statement last executed

Where @@trancount returns the number of Open Transactions in the Current Session

Suppose I have a Table TableA with 5 Rows

SELECT * FROM TableA

SELECT @@ROWCOUNT

Executing the Above I will get 2 Result sets, The first one will list all the 5 Rows of the TableA and Second will return the Number of Rows affected by the Query ie; 5

But If I run

SELECT * FROM TableA

SELECT @@TRANCOUNT

This will Return me the Number 0 for the 2nd result set as There are no Open Transactions (Begin Transaction)

BEGIN TRANSACTION

SELECT * FROM TableA

SELECT @@TRANCOUNT

COMMIT TRANSACTION

And This case will return 1 in the 2nd Result set as there is 1 Open Transaction in the Session

0

solved Is There any difference between rowcount and trancount [closed]