About

In SQL Server 2012, the ORDER BY clause syntax is extended by an optional OFFSET sub-clause:

ORDER BY order_by_expression
    [ COLLATE collation_name ] 
    [ ASC | DESC ] 
    [ ,...n ] 
[ <offset_fetch> ]


<offset_fetch> ::=
{ 
    OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS }
    [
      FETCH { FIRST | NEXT } {integer_constant | fetch_row_count_expression }
            { ROW | ROWS } ONLY
    ]
}

The OFFSET element specifies the number of rows to skip before it starts to return rows from the source query. The FETCH element specifies the number of rows to return after the OFFSET clause has been processed. Deterministic behaviour requires that the ORDER BY clause contains a column or combination of columns that form a unique key for the data set.

More details can be found in the Books Online documentation.

history | show excerpt | excerpt history