sql server分页查询,分享一个分页查询的sql语句,可用来研究sql server分页查询技术。
1,sql2000分布查询语句
select top @pagesize *
from table_name
where id not in
(
select top @pagesize*(@page-1) id
from table_name
order by id
) -- www.jb200.com
order by id
2,sql server 2005分页查询语句:
1)、sql server分页查询方法一:
select ...
from
(
select row_number() over (order by id asc) as rownum, ......
from table_name
) as t
where t.rownum> 10 and t.rownum<= 20
2)、sql server分页查询方法二:
with datalist as
(
select row_number() over (order by o.id desc)as rownum, ......
from .....
where ......
)
select ......
from datalist
where rownum between 10 and 20