Smile 笑容

sqlServer 标准查询代码分页技术

使用标准的SQL代码进行分页,通过动态合成查询语句来实现,简单易用,速度应该是不凡的。

例子:原 SQL
select
field1, field2 ...
from ab c, cd e where 1=1 and
c.id = d.id
order by c.id

分页, SQL更改为
select  top 30
field1, field2 ...
from ab c, cd e where 1=1 and
c.id = d.id

and c.id not in (
select top 200
c.id
from ab c, cd e where 1=1 and
c.id = d.id
order by c.id
)

order by c.id

其中 200是当前记录数,30是每页显示数