建设项目环境影响评价验收网站,咨询行业网站开发,做设计什么兼职网站,百度打广告多少钱一个月用存储过程实现数据库的分页代码,加快页面执行速度。具体的大家可以测试下。--*******************************************************--* 分页存储过程 *--* 撒哈拉大森林 *--* 2010-6-28 *--*******************************************************if exists(select * f…用存储过程实现数据库的分页代码,加快页面执行速度。具体的大家可以测试下。--*******************************************************--* 分页存储过程 *--* 撒哈拉大森林 *--* 2010-6-28 *--*******************************************************if exists(select * from sysobjects where typeP and nameNP_Paging)drop procedure P_Paginggocreate procedure P_PagingSqlStr nvarchar(4000), --查询字符串CurrentPage int, --第N页PageSize int --每页行数asset nocount ondeclare P1 int, --P1是游标的idrowcount intexec sp_cursoropen P1 output,SqlStr,scrollopt1,ccopt1,rowcountrowcount outputselect ceiling(1.0*rowcount/PageSize) as 总页数--,rowcount as 总行数,CurrentPage as 当前页set CurrentPage(CurrentPage-1)*PageSize1exec sp_cursorfetch P1,16,CurrentPage,PageSizeexec sp_cursorclose P1set nocount offgo----创建测试表--if exists(select * from sysobjects where typeU and nameNTest_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 i0-- 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 typeU and nameNTest_Students)-- drop table Test_Students--go