本文实例讲述了sql server实现分页的方法。分享给大家供大家参考,具体如下:
=
(
select max(doccode)
from
(
select top (@num * (@index - 1) + 1) doccode
from ppohd
order by doccode
) as tb
)
--分页3
select top (@num) *
from
(
select ppohd.doccode as 'mydoccode',row_number() over (order by doccode) as sno,*
from ppohd
) as tb
where tb.sno >= @num * (@index - 1) + 1
--分页4
select *
from
(
select ppohd.doccode as 'mydoccode',row_number() over(order by doccode) as sno,*
from ppohd
) as tb
where tb.sno between (@num * (@index - 1) + 1) and (@num * @index)
原文链接:https://www.f2er.com/mssql/62669.html