复制代码 代码如下:
--*******************************************************
--* 分页存储过程 *
--* 撒哈拉大森林 *
--* 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

更多相关文章

  1. android分页查询获取系统联系人信息
  2. Android入门教程(三十一)------SQLite分页读取
  3. android ListView的分段显示、分页显示(附源码)
  4. android左右滑动加载分页以及动态加载数据
  5. Android(安卓)listview怎么实现滚动分页
  6. Android(安卓)ListView专题之十二 分页不同的解决方案
  7. Android分页控件xlistview
  8. android中滑动SQLite数据库分页加载
  9. Android(安卓)分页组件

随机推荐

  1. Android 铃声和音量的获取程序
  2. (安卓权限)Android Permissions
  3. Notes on the implementation of encrypt
  4. Android 根据IP地址获取城市
  5. Android - Animation(一)
  6. android studio 在win10上弹出框过大,无法
  7. android 小部件 AndroidManifest.xml
  8. Android自学笔记(番外篇):全面搭建Linux环境
  9. Android(安卓)Intent
  10. android 2.3 电量管理