Checking the number of rows fetched

Use the @@rowcount global variable to monitor the number of rows of the cursor result set returned to the client up to the last fetch. This variable displays the total number of rows seen by the cursor at any one time.

Once all the rows are read from a cursor result set, @@rowcount represents the total number of rows in that result set. Each open cursor is associated with a specific @@rowcount variable. The variable is dropped when you close the cursor. Checking @@rowcount after a fetch provides you with the number of rows read for the cursor specified in that fetch.

The following example determines the @@rowcount for the currently open authors_crsr cursor:

select @@rowcount
---------
        5
 
(1 row affected)