sqlserver使用窗口函數(shù)實現(xiàn)分頁
alter proc [dbo].[usp_getstupage]
@pageindex int =1,--當前頁碼
@pagesize int =10,--頁容量
@pagecount int output--輸出總頁數(shù)
as
begin
select @pagecount=ceiling((count(id)*1.0)/@pagesize) from studentsinfo
select * from (
select *,row_number() over(order by id) as rownum from studentsinfo
)as t where t.rownum between (@pageindex-1)*@pagesize+1 and @pageindex*@pagesize
end
更多信息請查看IT技術專欄