[Company Logo Image] 

Home Up Contents Coffee Break Credits Glossary Links Search

Using Offset and Fetch with the Order By Clause



Analysis Services
CLR Integration
High Availability
Open Source
SQL Server 2008
SQL Server 2012
SQL Server 2014
SQL Server 2016
SQL Server 2017
SQL Server 2019

Using Offset and Fetch with the Order By Clause

Applies to: Microsoft SQL Server 2012.

If you need to implement a query page solution, you no longer need to use the TOP clause. Starting SQL Server 2012 you can make use of the OFFSET and FETCH arguments of ORDER BY clause as demonstrated on the following example:

As you can see on the following example, you can use FETCH FIRST instead of FETCH NEXT, and use ROW instead of ROWS.

On the following example, we are not skipping any rows. We are starting on the first record, and retrieving the top hundred records.



ORDER BY clause.



.Send mail to webmaster@sqlcoffee.com with questions or comments about this web site.