首页 > 开发 > 综合 > 正文

SqlServer 分页查询

2024-07-21 02:47:49
字体:
来源:转载
供稿:网友
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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表