SQL Server 使用存储过程和rows_number()进行分页
--分页存储过程
create proc usp_GetMyPhotos
@pageIndex int, --当前页码
@pageSize int, --每页多少条
@pageCount int output --计算 总共多少页
as
declare @count int --总共多少条
select @count =COUNT(*) from Photos
set @pageCount = CEILING( @count*1.0/@pageSize)
select * from
(select *,ROW_NUMBER() over(order by pid desc) as num
from Photos) as t
where num between @pageSize*(@pageIndex-1) + 1 and @pageSize*@pageIndex