Monday , June 25 2018
Home / DataBase / SQL SERVER / sql server query pagination

sql server query pagination

From SQL Server 2012, Microsoft introduced a couple of T-SQL Enhancements. One of them is Query Pagination. In most of the applications, a common requirement is how to fetch the data from the database servers as page wise.

In earlier versions of SQL Server like SQL Server 2005/2008/R2, we can implement Pagination by using different techniques like ROW_NUMBER() function or CTE – Common Table Expression. where as n SQL Server 2012, Microsoft has introduced Pagination as a part of Select query in a Order By clause. Now you will have to use OFFSET and FETCH NEXT with the order by clause.

For this demonstration i am using AdventureWorks2008 , I have created a Stored Procedure which takes two parameters. First parameter takes the page number and the second parameter  no. of records for that page.

below is The stored procedure:


exec GetRecords 1,10


exec GetRecords 2,10



We hope you find the tip as helpful,  I hope you liked the article. Please share your valuable suggestions and feedback in the comments

Print Friendly, PDF & Email

Give us your valuable feedback


About Murali

Hello everyone I am Software Developer having 3+ years of Experience in Microsoft Technologies and Others. My skills :-, C#,, SQL SERVER, web services, windows Service,Windows applications,HTML,CSS, JavaScript,JQuery,AnjularJs

Check Also


dbForge Studio for SQL Server – Ultimate SQL Server Manager Tool from Devart

dbForge Studio for SQL Server is a powerful IDE for SQL Server management, administration, development, …

%d bloggers like this: