Click here to Skip to main content
13,054,018 members (90,911 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have lots of data in my table. I want to display first 20 rows in html table. when i click next then next 20 rows will be displayed. is there any stored procedure with two parameters, start index and end index.. and data in between both parameter will be displayed???????????
Posted 12-Jan-14 18:23pm
Updated 12-Jan-14 18:24pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

declare @pageSize int = 20
declare @page int = 5
;with data
select row_number() over (order by modifieddate) as rowNo, salesOrderId, UnitPrice, OrderQty from Sales.salesorderdetail
select * from data where rowNo >= ((@page - 1) * @pageSize) and rowNo < (@page * @pageSize);

From this[^] article, which I only published today.
KARTHIK Bangalore 13-Jan-14 0:34am
5! Good
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Kim Togo 13-Jan-14 5:36am
Okay, then use Solution 1 by Christian.
Christian Graus 13-Jan-14 17:03pm
Wow - thanks, I did not know that. I just wrote an article, now I need to update it :-)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 13 Jan 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100