Pages

Search This Blog

Tuesday, December 14, 2010

[T-SQL] Paging in SQL Server 2011

So here is now the new feature of sql server in its latest edition , so here is how you can use paging , i mean server side paging for fetching rows or result set in pages.

USE AdventureWorks2008R2
GO
DECLARE @RowsPerPage INT = 10, @PageNumber INT = 5
SELECT *
FROM Sales.SalesOrderDetail
ORDER BY SalesOrderDetailID
OFFSET @PageNumber*@RowsPerPage ROWS
FETCH NEXT 10 ROWS ONLY
GO

No comments: