페이지 저장 프로세스(저장 프로세스로 데이터베이스의 페이지 코드를 실현)

1825 단어
 
  
--*******************************************************
--* *
--* *
--* 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

좋은 웹페이지 즐겨찾기