简单而有实用的脚本,来自http://www.studyofnet.com/news/180.html
- 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
来源: https://www.oschina.net/code/snippet_2653731_58635