Many times, it is required to implement paging in SQL. Well you can find many ways to accomplish it but recently I came across to a very simple way of doind this.
Consider you want to find the records from 21-30 in order of their IDs, then you can do this using the folllowing query:
SELECT TOP pagesize *FROM (SELECT TOP (pagesize*pagenumber) * FROM tableName ORDER BY ID)
ORDER BY ID DESC.
Yup it is a very easy and handy way to implement paging.
Wednesday, December 28, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment