分页存储过程

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

 

posted on 2016-12-16 09:47  小瓢蟲  阅读(120)  评论(0编辑  收藏  举报