Returning limited number of records at a time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a continuous form which is bound to a query which returns a large
number of records causing performance problems. I'd like to be able to
return 100 records at a time and allow the user to press a next button to get
the next 100 records. I know how to get the first 100 records using the TOP
keyword in the select statement, but how can I then get the next 100 and the
next 100 etc.

Does anyone know an easy way to do this?
 
Dear Dan:

Pretty standard stuff, really.

The first 100 is the TOP 100, as you know.

The next 100 is the bottom 100 of the top 200. To do this:

SELECT * FROM (
SELECT TOP 100 *
FROM (
SELECT TOP 200 *
FROM YourTable
ORDER BY X, Y)
ORDER BY X Desc, Y Desc)
ORDER BY X, Y

I have flipped the order of this so it is forward again.

Tom Ellison
 
Back
Top