存储过程分页

sql:

jquery :http://luis-almeida.github.io/jPages/pagination.html

USE [RoyalTravel]
GO
/****** Object:  StoredProcedure [dbo].[p_splitpage]    Script Date: 10/22/2013 14:00:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[p_splitpage]   
@sql nvarchar(4000),    --要执行的sql语句
@page int=1,             --要显示的页码
@pageSize int,            --每页的大小
@pageCount int=0 out,    --总页数
@recordCount int=0 out    --总记录数
as
set nocount on
declare @p1 int
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
set @recordCount = @pageCount
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
    ,@page=(@page-1)*@pagesize+1
exec sp_cursorfetch @p1,16,@page,@pagesize 
--exec sp_cursorclose @p1

c#方法:
http://www.debugease.com/aspdotnet/956556.html

 

 

 

 

 

 

posted @ 2013-10-22 14:02  觉信  阅读(188)  评论(0编辑  收藏  举报