SQL2005 ROW_NUMER实现分页的两种常用方式

前端之家收集整理的这篇文章主要介绍了SQL2005 ROW_NUMER实现分页的两种常用方式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码如下:
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) 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,
* from tb
) as page_table
where row_num > (@PageNumber - 1) * @PageSize
order by row_num
[/code]

原文链接:https://www.f2er.com/mssql/66433.html

猜你在找的MsSQL相关文章