供大家学习参考。
---row_number分页实例
---by http://www.jb200.com
declare @PageNumber int
declare @PageSize int
set @PageNumber=2
set @PageSize=20
--使用between方式
select *
from
(
select
row_number() over (order by source_ip,id) as row_num,
* from tb_test_news) as page_table
where row_num between (@PageNumber - 1) * @PageSize + 1 and @PageNumber * @PageSize
--保用top方式
select top 20 *
from
(
select
row_number() over (order by source_ip,id) as row_num,
* from tb_test_news
) as page_table
where row_num > (@PageNumber - 1) * @PageSize
order by row_num