Top n, Mid n, is there a native way?

  • Hi,

    I am trying to retrieve 20 records from a recordset starting at record number 21, or 41 or 61... etc. This will alow me to use a system similar to the Googles of the world, where you are viewing page x of 200 and can click prev, next.

    I can achieve this by manipulating the AbsolutePage value of an ADO Recordset object if the Sql Statement is contained in a VbScript ASP page. The problem with this approach is that SQL must return all records to the web application, and the web application chooses to show only 20 rows. Also, if the SQL statement is in a Stored Procedure which is fired by the ASP page, the AbsolutePage property seems to behave different.

    Is there a native way to achieve what I want in SQL Server (2000) using T-SQL. A sort of

    Select Mid(21,40) * from Products order by Name

    Many thanks for reading this far

    Conway

  • Hi Ken,

    Thanks for that. Initial testing looks good (on a simple "Flat" table), I am going to try to adapt it so it works with a more complex multi table grouped select and see what happens.

    Best Regards

    Conway

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply