代码改变世界

SQL Server 使用ROW_NUMBER实现的高效分页排序

2014-05-06 17:23  taozsay  阅读(267)  评论(0编辑  收藏  举报
declare @pageNum int
set @pageNum=1
declare @pageSize int
set @pageSize=10
select * from (select ROW_NUMBER() over(order by a_CreationTime desc) as rowNum,* from td_Articles) as c 
where rowNum between((@pageNum-1) * @pageSize+1) and @pageNum * @pageSize

 

参考:http://www.cnblogs.com/seusoftware/p/3272632.html