SET ROWCOUNT

SET ROWCOUNT#

In SQL Server, causes the engine to stop processing a query after the specified number of rows are returned.

Note

Not to be confused with @@ROWCOUNT (@@ROWCOUNT), the function that reports how many rows the previous statement affected — an unrelated, read-only value.

Syntax#

SET ROWCOUNT { number | @number_var }

Arguments#

number | @number_var

Is the number, an integer, of rows to be processed before stopping the specific query.

Remarks#

SET ROWCOUNT is parsed and accepted, but the row limit is not currently enforced — statements run as if no limit were set, regardless of the value passed. Use TOP instead to limit the number of rows a query returns.

Permissions#

Requires membership in the public role.

See Also#