第一种是最传统的写法,用存储过程中的变量作为分页的乘数
复制代码 代码如下:
[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分页查询(推荐)
- 真正高效的SQLSERVER分页查询(多种方案)
- 分页 SQLServer存储过程
- sqlserver 通用分页存储过程
- sqlserver 三种分页方式性能比较[图文]
- 基于sqlserver的四种分页方式总结
- sqlserver分页查询处理方法小结
- sqlserver 存储过程分页代码
- SQL server分页的4种方法示例(很全面)