时间:2021-07-01 10:21:17 帮助过:273人阅读
max/top 分页方式
1.原始的
select * from dbo.pagetest where id >(select max(id) from (select top(9900) id from dbo.pagetest order by id)a) order by id
2.封装存储过程
create Proc pageSeparate(
@count int, -- 数据条数
@tabName nvarchar(50), --表名
@pageIndex int --区间 多少也开始查询
)
as
begin
declare @sqlStr nvarchar(max)
set @sqlStr = ‘select * from ‘+@tabName+‘ where id >(select max(id) from (select top(‘+cast((@pageIndex*@count)as nvarchar(20))+‘) id from ‘+@tabName +‘ order by id)a) order by id‘
print @sqlStr
exec(@sqlStr)
end
sql 分页查询
标签:span get 分页查询 roc begin 开始 查询 var --