gpt4 book ai didi

分页存储过程(用存储过程实现数据库的分页代码)

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 24 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章分页存储过程(用存储过程实现数据库的分页代码)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

代码如下

--*******************************************************  --* 分页存储过程 *  --* 撒哈拉大森林 *  --* 2010-6-28 *  --*******************************************************  if exists(select * from sysobjects where type='P' and name=N'P_Paging')  drop procedure P_Paging  go  create procedure P_Paging  @SqlStr nvarchar(4000), --查询字符串  @CurrentPage int, --第N页  @PageSize int --每页行数  as  set nocount on  declare @P1 int, --P1是游标的id  @rowcount int  exec sp_cursoropen @P1 output,@SqlStr,@scrollopt=1,@ccopt=1,@rowcount=@rowcount output  select ceiling(1.0*@rowcount/@PageSize) as 总页数--,@rowcount as 总行数,@CurrentPage as 当前页  set @CurrentPage=(@CurrentPage-1)*@PageSize+1  exec sp_cursorfetch @P1,16,@CurrentPage,@PageSize  exec sp_cursorclose @P1  set nocount off  go  ----创建测试表  --if exists(select * from sysobjects where type='U' and name=N'Test_Students')  -- drop table Test_Students  --go  --create table Test_Students(  -- id int IDENTITY(1,1) not null,  -- name nvarchar(100) not null  --)  --  ----创建测试数据  --declare @i int  --set @i = 100000  --while @i>0  -- begin  -- insert into Test_Students values('姓名')  -- set @i = @i - 1  -- end  --  ----执行存储过程  --exec P_Paging 'select * from Test_Students order by id',100,100 --执行  --  ----删除测试表  --if exists(select * from sysobjects where type='U' and name=N'Test_Students')  -- drop table Test_Students  --go 。

最后此篇关于分页存储过程(用存储过程实现数据库的分页代码)的文章就讲到这里了,如果你想了解更多关于分页存储过程(用存储过程实现数据库的分页代码)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com