Click here to Skip to main content
13,143,637 members (28,988 online)
Click here to Skip to main content
Alternatives (3)
Add your own
alternative version

Tagged as


27 bookmarked
Posted 27 Dec 2011

Efficient paging using SQL script

, 16 Jan 2012
How to create an efficient paging using SQL script


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

10 Jan 2012
Take a look at this:DECLARE @ActualRow = 1; /*Start in first item*/DECLARE @ItensCount = 100; /*100 itens for page*/DECLARE @Page = 1; /*Start in first page*/SELECT * FROM(SELECT *, ROWNUMBER() OVER(ORDER BY Name) as ROWNUM FROM Users) as UsWHERE ROWNUM BETWEEN...
28 Dec 2011
Hi, what about such solution?DECLARE @pageNumber INTDECLARE @rowsOnPage INTSET @rowsOnPage=5SET @pageNumber=2DECLARE @totalItemsToSelect INTSET @totalItemsToSelect=@rowsOnPage * @pageNumberSELECT TOP (@rowsOnPage) * FROM MainTrans WHERE ID IN( SELECT TOP...
10 Jan 2012
string Query = string.Format(@"SELECT * FROM (SELECT *, " + @"ROW_NUMBER() OVER(ORDER BY PRODUCT_ID DESC ) AS ROW_NUM FROM({0}) " + @"AS TEMP_INNER) AS TEMP_OUTER WHERE ROW_NUM BETWEEN '{1}' AND " + @"({2} + {3}) - 1", strSql, startRowIndex, startRowIndex, maximumRows);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Robby Tendean
Software Developer
Singapore Singapore
Robby Tendean had his Master Degree in Computer Science from National Taiwan University of Science and Technology. His master degree thesis, Energy-Efficient Routing Protocol for Wireless Sensor Networks with Static Clustering and Dynamic Structure, has been published in Springerlink International Journal.

Currently he is working as Software Engineer based in Singapore with several years experience in HTML, Javascript, JQuery, C#.NET, VB.NET, Microsoft SQL Server for web development.

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 16 Jan 2012
Article Copyright 2011 by Robby Tendean
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid