Possible Duplicate:
Equivalent of LIMIT and OFFSET for SQL Server?
I am working on a table which currently contains 2500 rows, and will be much more and more in future.
I am using jqgrid to display the records from the database .
Whenever the grid is loading, I am retrieving the top 500
rows from the database. However when I am started using pagination in the grid, the number of records is adding.
Example : first the number of rows is TOP 100
, then going onto the next page its increased to TOP 200
and so on in the query.
Now I want a solution to avoid this issue such that I can limit the rows instead of retrieving top n rows based on the grid. Say using a range or LIMIT
Example
When I am navigating to next page in grid, instead of TOP 200
rows I want to fetch rows from 101 to 200
select top 500
exe.id,
bat.BName,
bat.tid,
bat.freq,
exe.status,
exe.Msg,
exe.time,
exe.Fi
from
XXX exe,
YYY bat
where
exe.id=bat.id
order by
CONVERT(VARCHAR(10),
exe.time,
120) DESC,
exe.status,
exe.id DESC
Please guide me in this, as I am new to jQGrid and not much aware how to handle this DB related stuff
I also referred few links in Stackoverflow but can't understand
Thanks in advance