Click here to Skip to main content
12,403,391 members (71,284 online)
Rate this:
 
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 18:23pm
rhl4569917
Updated 12-Jan-14 18: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 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 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.160721.1 | Last Updated 13 Jan 2014
Copyright © CodeProject, 1999-2016
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