@@ROWCOUNT
reads prior-statement state
What changes
- Input
- row count of the previous statement
- Output or change
- int
- Return type
- int
Syntax at a glance
@@ROWCOUNT
Work example
Check how many rows the immediately preceding statement affected.
Copy @@ROWCOUNT to a variable before running another statement that can reset it.
Check your work Many statements reset or replace @@ROWCOUNT, so a later read may describe the wrong operation.
Practice SQL
Open in SQL FlowSELECT @@ROWCOUNT AS rows_from_previous_statement;
Open Microsoft Learn for full syntax, permissions, and details for your version.