SQL Flow Field Guide

@@ROWCOUNT

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

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 Flow
SELECT @@ROWCOUNT AS rows_from_previous_statement;

Open Microsoft Learn for full syntax, permissions, and details for your version.