当前位置: 代码迷 >> Sql Server >> 看不懂的存储过程,请帮忙解释一下,该如何解决
  详细解决方案

看不懂的存储过程,请帮忙解释一下,该如何解决

热度:68   发布时间:2016-04-27 21:19:37.0
看不懂的存储过程,请帮忙解释一下
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



------解决方案--------------------
是微软未公开的存储过程之一. 看不到源代码.