您的位置:首页 > 数据库

Sql Server 存储过程分页

2015-11-15 11:01 393 查看
create proc usp_GetMyPhotos
@pageIndex int,   --当前页码
@pageSize int,   --每页多少条
@pageCount int output  --计算  总共多少页
as
declare @count int --总共多少条
select @count =COUNT(*) from room
set @pageCount = CEILING( @count*1.0/@pageSize)
select * from
(select *,ROW_NUMBER() over(order by ids desc) as num
from room) as t
where num between @pageSize*(@pageIndex-1) + 1 and @pageSize*@pageIndex

declare @n int
exec usp_GetMyPhotos 4,3,@n output
print @n
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: