ORDER BY ... OFFSET ... FETCH
page limit after OFFSET
What changes
- Input
- rows after OFFSET
- Output or change
- at most N rows
Syntax at a glance
OFFSET n ROWS FETCH { FIRST | NEXT } { integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY
Work example
A result page needs ORDER BY ... OFFSET ... FETCH with a stable key order before rows are skipped or returned.
Sort by a unique key as the final tie-breaker. Request adjacent pages and check that no row is skipped or repeated.
Check your work ORDER BY ... OFFSET ... FETCH. The result order for ORDER BY ... OFFSET ... FETCH is repeatable and page boundaries have no gaps or duplicates.
Open Microsoft Learn for full syntax, permissions, and details for your version.