答案:复制代码 代码如下:
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,id) as row_num,
* from tb
) as page_table
where row_num > (@PageNumber - 1) * @PageSize
order by row_num
[/code]
上一个:Sql Server 2005 默认端口修改方法
下一个:SQL2008中 阻止保存要求重新创建表的更改 的解决方法