您的位置:首页 > 数据库

sqlserver 开窗函数分页

2015-09-24 09:25 344 查看
if exists(select * from sysobjects where name='usp_getPageData')
drop proc usp_getPageData
go
create procedure usp_getPageData
@totalPage int output,--总页数
@pageIndex int =1 ,--当前页码,默认是第一页
@pageCount int =5 --每一页显示的记录数
as
select * from (select ROW_NUMBER() over(order by studentno) id,* from Student) temp where temp.id>(@pageindex-1)*@pagecount and temp.id<=(@pageindex*@pagecount)
set @totalPage=CEILING((select COUNT(*) from Student)*1.0/@pageCount)
go
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: