CREATE PROCEDURE PAGINATION_JHGL
@SQL text, @Curpage int = 1, @PageSize int
AS
SET nocount ON
DECLARE @h int
SET @CurPage = (@CurPage-1)*@PageSize + 1
EXEC sp_cursoropen @h output, @sql, 1
EXEC sp_cursorfetch @h, 16, @CurPage, @PageSize
EXEC sp_cursorclose @h
SET nocount OFF
GO