ROWCOUNT_BIG

ROWCOUNT_BIG#

Returns the number of rows affected by the most recently completed statement in the current session — the same value as @@ROWCOUNT, but as a bigint, for counts beyond the int range. Querona evaluates ROWCOUNT_BIG() in memory; it is never pushed down to a source.

Syntax#

ROWCOUNT_BIG ( )

Return types#

bigint

Remarks#

ROWCOUNT_BIG() follows exactly the same per-statement rules as @@ROWCOUNT — the only difference is the return type. See @@ROWCOUNT for the full statement-by-statement semantics (what resets it to 0, what leaves it unchanged, and the batch-sequencing gotcha where reading the value is itself a statement).

Use ROWCOUNT_BIG() rather than @@ROWCOUNT whenever a statement can affect more than 2 147 483 647 rows: @@ROWCOUNT truncates such a count to 32 bits and can report a negative value, while ROWCOUNT_BIG() reports it in full.

SET NOCOUNT ON suppresses only the rows-affected message sent to the client — it does not affect ROWCOUNT_BIG(). See SET NOCOUNT.

SET ROWCOUNT is an unrelated statement (a session-level row limit) despite the similar name; see SET ROWCOUNT.

Example#

DELETE FROM dbo.Log WHERE LogDate < '2020-01-01';
SELECT ROWCOUNT_BIG() AS RowsDeleted;

See Also#