Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting rows returned

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
How do I limit the number of rows returned by a query i.e.

return 10 results starting with the 5th (as with mysql's limit 5,10)

Cheers
 
Presume you're paging?

Its not too easy to start from, with a limit without running through a CURSOR, unless you know what the row, or keyed order you're starting from.

If you do then you can either
select top 10 ... from ...
order by 'key'
where 'key' > known_value

or ;
set rowcount 10
select ... from ...
order by 'key'
where 'key' > known value

Other client side alternatives may be a better solution.


 
Set Rowcount @RecordNumber

ISQL Query

Set Rowcount 0 (Doing This Also important Otherwise All Queries will Return @RecordNumber for U'r Entire Session )

Regards
Nikhil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top