最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

分頁存儲過程(用存儲過程實(shí)現(xiàn)數(shù)據(jù)庫的分頁代碼)

 更新時間:2010年06月29日 09:01:31   作者:  
用存儲過程實(shí)現(xiàn)數(shù)據(jù)庫的分頁代碼,加快頁面執(zhí)行速度。具體的大家可以測試下。
復(fù)制代碼 代碼如下:

--*******************************************************
--* 分頁存儲過程 *
--* 撒哈拉大森林 *
--* 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 --每頁行數(shù)
as
set nocount on
declare @P1 int, --P1是游標(biāo)的id
@rowcount int
exec sp_cursoropen @P1 output,@SqlStr,@scrollopt=1,@ccopt=1,@rowcount=@rowcount output
select ceiling(1.0*@rowcount/@PageSize) as 總頁數(shù)--,@rowcount as 總行數(shù),@CurrentPage as 當(dāng)前頁
set @CurrentPage=(@CurrentPage-1)*@PageSize+1
exec sp_cursorfetch @P1,16,@CurrentPage,@PageSize
exec sp_cursorclose @P1
set nocount off
go


----創(chuàng)建測試表
--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
--)
--
----創(chuàng)建測試數(shù)據(jù)
--declare @i int
--set @i = 100000
--while @i>0
-- begin
-- insert into Test_Students values('姓名')
-- set @i = @i - 1
-- end
--
----執(zhí)行存儲過程
--exec P_Paging 'select * from Test_Students order by id',100,100 --執(zhí)行
--
----刪除測試表
--if exists(select * from sysobjects where type='U' and name=N'Test_Students')
-- drop table Test_Students
--go
您可能感興趣的文章:

相關(guān)文章

最新評論

屏东市| 渭南市| 金乡县| 赣州市| 庆云县| 阿拉善盟| 徐闻县| 东明县| 图片| 平江县| 繁昌县| 个旧市| 即墨市| 高唐县| 沈丘县| 麻阳| 乡城县| 昭通市| 霸州市| 郎溪县| 桂东县| 黎川县| 林芝县| 和平县| 邯郸县| 新源县| 蕉岭县| 建始县| 岑巩县| 镇原县| 保德县| 论坛| 灵丘县| 康乐县| 同江市| 宁都县| 仙游县| 通州市| 礼泉县| 措勤县| 安图县|