SqlServer 分页查询


SqlServer 分页查询1.not in方法select top 10 from books where id not in(select top 30 id from books)2.row_number()函数select * from (select *,row_number() over (order by id) numfrom books) a where num between 31 and 403.存储过程分页create PRoc proc_AdminPages@pageIndex int,--当前页码@pageSize int--每页数量asdeclare @begin int,@end int--定义局部变量set @begin=@pageSize*(@pageIndex-1)+1--赋值set @end=@pageSize*@pageIndexselect * from (select ROW_NUMBER() over(order by id) as RowIndex,* from Admin) awhere RowIndex between @begin and @end--执行exec proc_AdminPages 2,1