求一段sql server 存储过程的代码 用以实现JSP中分页

我用的是sqlserver2008我想用存储过程的方法把数据库中news表中的title,content等属性分页显示在jsp页面,但是存储过程总写不对,求高手指点迷津呵... 我用的是sql server 2008
我想用存储过程的方法把数据库中news表中的title,content等属性分页显示在jsp页面,但是存储过程总写不对,求高手指点迷津 呵呵。。。
展开
 我来答
匿名用户
2013-11-11
展开全部
/*分页查找数据*/
  CREATE PROCEDURE [dbo].[GetRecordSet]
  @strSql varchar(8000),--查询sql,如select * from [news]
  @PageIndex int,--查询当页号
  @PageSize int--每页显示记录
  AS
  set nocount on
  declare @p1 int
  declare @currentPage int
  set @currentPage = 0
  declare @RowCount int
  set @RowCount = 0
  declare @PageCount int
  set @PageCount = 0
  exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --得到总记录数
  select @PageCount=ceiling(1.0*@rowCount/@pagesize) --得到总页数
  ,@currentPage=(@PageIndex-1)*@PageSize+1
  select @RowCount,@PageCount
  exec sp_cursorfetch @p1,16,@currentPage,@PageSize
  exec sp_cursorclose @p1
  set nocount off
  GO
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式