Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET SQL-Server
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 19:23pm
rhl4569822
Edited 12-Jan-14 19:24pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

declare @pageSize int = 20
declare @page int = 5
 
;with data
as
(
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.
  Permalink  
Comments
KARTHIK Bangalore at 13-Jan-14 0:34am
   
5! Good
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Kim Togo at 13-Jan-14 5:36am
   
Okay, then use Solution 1 by Christian.
Christian Graus at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.150305.1 | Last Updated 13 Jan 2014
Copyright © CodeProject, 1999-2015
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