If you are using SQL Server 2000, you have a number of options which are explained here:
http://databases.aspfaq.com/database/how-do-i-page-through-a-recordset.html. The article looks at paging records in classic ASP. so the first half of the article is irrelevant, but further down, there are a number of stored procedure options that work.
Aaron Bertrand found the last Stored Procedure options - the one that uses ROWCOUNT to be the best performer. Don't just grab the first one in the list.
nkd1083
Member
397 Points
298 Posts
select rows between 15 to 30 from sql server
Jul 27, 2010 01:07 PM|LINK
i want to select rows between 15 to 30 from sql server so i am writing this:
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">SELECT uid, nname, nemail, ntelephone, naddress, ndate, uname, upassword, usertype, umonth, nregistration, regdate, paydetail, servicetype, serviceperiod, </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> uip, lname, paytype, ntelephoneoptional, nallow, nvalue, expdate</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">FROM registration</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">WHERE (rownum > 2) AND (rownum < 10)</div>SELECT *
FROM registration
WHERE (rownum > 14) AND (rownum < 31)
but i am getting error: "No value given for one or more required parameter" ..
plz reply me..
sansan
All-Star
53942 Points
8147 Posts
Re: select rows between 15 to 30 from sql server
Jul 27, 2010 03:37 PM|LINK
try like this
You have to calculate the row number and then apply the filter
nkd1083
Member
397 Points
298 Posts
Re: select rows between 15 to 30 from sql server
Jul 28, 2010 06:31 AM|LINK
thanks for reply ,
after applying this query i am getting error:" ROW_NUMBER is not a recognizes function name". I am using sql server 2000
plz reply me
sansan
All-Star
53942 Points
8147 Posts
Re: select rows between 15 to 30 from sql server
Jul 28, 2010 06:43 AM|LINK
Honestly, I'm sorry I have never worked on SQL Server 2000. I think that Row Number function is from 2205.
check this link:
http://www.codeproject.com/KB/database/Row_numbers_in_SQL_Query.aspx
Mikesdotnett...
All-Star
154957 Points
19873 Posts
Moderator
MVP
Re: select rows between 15 to 30 from sql server
Jul 28, 2010 06:53 AM|LINK
If you are using SQL Server 2000, you have a number of options which are explained here: http://databases.aspfaq.com/database/how-do-i-page-through-a-recordset.html. The article looks at paging records in classic ASP. so the first half of the article is irrelevant, but further down, there are a number of stored procedure options that work. Aaron Bertrand found the last Stored Procedure options - the one that uses ROWCOUNT to be the best performer. Don't just grab the first one in the list.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter