sqlserver分页的两种写法分别介绍
来源:asp之家 时间:2024-01-24 15:58:18
第一种是最传统的写法,用存储过程中的变量作为分页的乘数
代码如下:
[c-sharp] view plaincopyprint?create proc p_paged1
@pageSize int,@currentPage int
as
select top (@pageSize) * from student
where id not in
(select top (@pageSize*(@currentPage-1)) id from student)
go
exec p_paged1 2,3
create proc p_paged1
@pageSize int,@currentPage int
as
select top (@pageSize) * from student
where id not in
(select top (@pageSize*(@currentPage-1)) id from student)
go
exec p_paged1 2,3
--SQL Server2005以后的分页语句
代码如下:
[c-sharp] view plaincopyprint?create proc p_paged2
@pageStart int, @pageEnd int
as
select * from
(select *,row_number() over(order by id desc) as rnum
from student) t
where t.rnum between @pageStart and @pageEnd
go
exec p_paged2 5,10
标签:sqlserver分页
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Yahoo! BrowserPlus 发布
2008-11-20 13:35:00
Pandas中如何对DataFrame列名进行重命名
2021-06-14 23:46:38
python实现批量视频分帧、保存视频帧
2023-07-04 19:59:18
Python响应对象text属性乱码解决方案
2023-07-31 13:06:41
![](https://img.aspxhome.com/file/2023/0/61170_0s.png)
SQLite Delete详解及实例代码
2024-01-12 17:15:46
python实现TCP服务器端与客户端的方法详解
2023-05-17 09:39:39
如何利用饰器实现 Python 函数重载
2022-10-16 20:42:41
SQL解决未能删除约束问题drop constraint
2024-01-24 20:08:09
![](https://img.aspxhome.com/file/2023/2/98042_0s.png)
MySQL 数据库的基础知识
2024-01-17 03:05:52
![](https://img.aspxhome.com/file/2023/1/99341_0s.png)
教你用python从日期中获取年、月、日和星期等30种信息
2023-05-06 22:32:38
![](https://img.aspxhome.com/file/2023/1/102861_0s.png)
关于Python-faker的函数效果一览
2023-12-02 21:20:06
python安装cx_Oracle和wxPython的方法
2022-07-31 11:33:04
![](https://img.aspxhome.com/file/2023/1/93451_0s.png)
设置mysql最大连接数的方法
2010-12-03 16:00:00
Python实现爬取亚马逊数据并打印出Excel文件操作示例
2021-09-10 05:10:36
![](https://img.aspxhome.com/file/2023/3/105203_0s.png)
Opera下cloneNode的bug
2007-11-23 11:40:00
通过事务日志解决SQL Server常见四大故障(二)
2009-03-25 13:51:00
八卦调侃Reset CSS
2010-01-13 13:01:00
也谈谈DIV+CSS的牛角尖
2007-11-16 16:12:00
在Python的Flask框架下使用sqlalchemy库的简单教程
2021-02-23 23:58:40
Python中的对象,方法,类,实例,函数用法分析
2022-12-13 22:01:38