SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create PROC SP_pagination2
(
@sqlstr nvarchar(4000), --查询字符串
@pagecount 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,@[email protected] output
select @rowcount as 总行数,ceiling([email protected][email protected]) as 页数,@pagecount as 当前页
set @pagecount=(@pagecount-1)[email protected]+1
exec sp_cursorfetch @P1,16,@pagecount,@pagesize
exec sp_cursorclose @P1
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
------解决方案--------------------
是微软未公开的存储过程之一. 看不到源代码.