MSSQL数据库分页存储过程
create procedure [dbo].[p_splitpage] @sql nvarchar(4000), @currentpage int=2, @pagesize int=10, @recordcount int=0 output, @pagecount int=0 output as set nocount on declare @p1 int exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output set @recordcount=@pagecount set @pagecount=ceiling(1.0*@pagecount/@pagesize) set @currentpage=(@currentpage-1)*@pagesize+1 select @recordcount recordcount ,@pagecount pagecount,@currentpage currentpage exec sp_cursorfetch @p1,16,@currentpage,@pagesize exec sp_cursorclose @p1 set nocount off GO