MS SQL Paging

Fezi
Fezi used Ask the Experts™
on
Hi Experts,

I want to do a paging, in SQL.

In mySQL its simple,

SELECT * FROM sdslist LIMIT 10,30

can I do anything like this in SQL? it's pretty simple what I want to do, just a simple paging.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
try

select *
from (select *, row_number() over(order by your_order_column_here) rown
         from your_table) t
where rown between 30 and 30+10
Commented:
there are 2 ways here

1) SELECT * FROM
    (SELECT TOP 10 * FROM
     (SELECT TOP 30 * FROM tablename AS T1 ORDER BY Fieldname ASC)
   AS T2 ORDER BY Fieldname DESC)
T3 ORDER BY Fieldname ASC

and second is as mentioned by momi_sabag using Row number

2)

select *
from (select *, row_number() over(order by your_order_column_here) rown
         from your_table) t1
where rown between 10 and 30

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial