
求一段sql server 存储过程的代码 用以实现JSP中分页
我用的是sqlserver2008我想用存储过程的方法把数据库中news表中的title,content等属性分页显示在jsp页面,但是存储过程总写不对,求高手指点迷津呵...
我用的是sql server 2008
我想用存储过程的方法把数据库中news表中的title,content等属性分页显示在jsp页面,但是存储过程总写不对,求高手指点迷津 呵呵。。。 展开
我想用存储过程的方法把数据库中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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询