create proc pageproc
@pageIndex int,
@pageSize int
as
begin
declare cur cursor scroll for select stuName,stuno from stuInfo
declare @count int
declare @name varchar(20)
declare @no varchar(20)
set @count=(@pageIndex-1)*@pageSize+1
open cur
fetch absolute @count from cur into @name,@no
while @count<=@pageSize*@pageIndex and @@FETCH_STATUS=0
begin
print @name+' '+@no
set @count=@count+1
fetch absolute @count from cur into @name,@no
end
close cur
deallocate cur
end
go
SqlServer中使用游标实现分页效果
最新推荐文章于 2024-08-21 11:29:11 发布
本文将介绍如何使用SQL语句实现数据分页查询,包括使用游标和变量的技巧,以及通过设置偏移量来获取指定页的数据。通过实例演示,帮助开发者理解并掌握SQL分页查询的基本操作。
167

被折叠的 条评论
为什么被折叠?



