方法1:top方式分页
--查询第一页
select top 5 * from student
--查询第二页
select top 5 *from student where stuid not in (select top 5 stuid from student)
--查询第三页
select top 5 *from student where stuid not in (select top 10 stuid from student)
综上所述:得出规律:
select top 页码大小 *from student where stuid not in(select top 页码大小*(当前页-1)stuid from student)
方法2:row_number分页
格式:
row_number() over(order by 主键)
例:
select row_number() over(order by stuid) as Rowid,*from student where Rowid between ((当前页-1)*页码大小+1) and (当前页*页码大小)