第一种是最传统的写法,用存储过程中的变量作为分页的乘数复制代码代码如下:[c-sharp]viewplaincopyprint?createprocp_paged1@pageSizeint,@currentPageintasselecttop(@pageSize)*fromstudentwhereidnotin(selecttop(@pageSize*(@currentPage-1))idfromstudent)goexecp_paged12,3createprocp_paged1@pageSizeint,@currentPageintasselecttop(@pageSize)*fromstudentwhereidnotin(selecttop(@pageSize*(@currentPage-1))idfromstudent)goexecp_paged12,3--SQLServer2005以后的分页语句复制代码代码如下:[c-sharp]viewplaincopyprint?createprocp_paged2@pageStartint,@pageEndintasselect*fro
第一种是最传统的写法,用存储过程中的变量作为分页的乘数
[c-sharp] view plaincopyprint?create proc p_paged1
@pageSize int,@currentPage int
as
select top (@pageSize) * from student
where id not in
(select top (@pageSize*(@currentPage-1)) id from student)
go
exec p_paged1 2,3
create proc p_paged1
@pageSize int,@currentPage int
as
select top (@pageSize) * from student
where id not in
(select top (@pageSize*(@currentPage-1)) id from student)
go
exec p_paged1 2,3
--SQL Server2005以后的分页语句
[c-sharp] view plaincopyprint?create proc p_paged2
@pageStart int, @pageEnd int
as
select * from
(select *,row_number() over(order by id desc) as rnum
from student) t
where t.rnum between @pageStart and @pageEnd
go
exec p_paged2 5,10
声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!