ROW_COUNT option

Function

Limits the number of rows returned from a query.

Allowed values

Integer.

Scope

DBA permissions are not required to set this option. Can be set temporary, for an individual connection, or for the PUBLIC group. Takes effect immediately.

Default

0 (no limit on rows returned).

Description

When this run-time option is set to a non-zero value, query processing stops after the specified number of rows.

This option only affects statements with the keyword SELECT. It does not affect UPDATE and DELETE statements.

The SELECT statement keywords FIRST and TOP also limit the number of rows returned from a query. FIRST returns the first row and is equivalent to setting ROW_COUNT equal to 1. TOP returns a specified number of rows and is the same as setting ROW_COUNT equal to the same number of rows. TOP has an upper limit of 32767, but ROW_COUNT has no upper limit. If both TOP and ROW_COUNT are set, the value of TOP takes precedence.

See also

“QUERY_ROWS_RETURNED_LIMIT option”

SELECT statement