sql分页定义存储过程
2012-02-27 20:29
295 查看
USE [cellcenter]
GO
/****** Object: StoredProcedure [dbo].[fenyede] Script Date: 02/27/2012 20:30:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
createPROCEDURE [dbo].[fenyede]
@pageSize int, --每页记录数量
@pageCount int output, --总页数
@pageIndex int --当前页索引号
AS
BEGIN
declare @totalRecords int
select @totalRecords = count(id) from users
if(@totalRecords % @pageSize = 0)
set @pageCount = @totalRecords / @pageSize;
else
set @pageCount = @totalRecords / @pageSize +1;
with temp as (select row_number() over (order by id) as sid,* from users)
select username,xingming,power from temp where power !='客户' and id between (@pageIndex -1)*@pageSize +1 and @pageIndex * @pageSize
return @totalRecords
end
GO
/****** Object: StoredProcedure [dbo].[fenyede] Script Date: 02/27/2012 20:30:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
createPROCEDURE [dbo].[fenyede]
@pageSize int, --每页记录数量
@pageCount int output, --总页数
@pageIndex int --当前页索引号
AS
BEGIN
declare @totalRecords int
select @totalRecords = count(id) from users
if(@totalRecords % @pageSize = 0)
set @pageCount = @totalRecords / @pageSize;
else
set @pageCount = @totalRecords / @pageSize +1;
with temp as (select row_number() over (order by id) as sid,* from users)
select username,xingming,power from temp where power !='客户' and id between (@pageIndex -1)*@pageSize +1 and @pageIndex * @pageSize
return @totalRecords
end
相关文章推荐
- 数据库开发必看 -- 用索引优化SQL,开发优秀的分页存储过程(二)
- 使用系统存储过程实现的通用分页存储过程.sql
- sql 分页存储过程实例(二)
- sql 存储过程分页
- ms-sql 存储过程分页
- SQL与oracle分页存储过程
- [MSSQL]SQL通用存储过程分页,支持多表联合
- SQL分页的存储过程详解
- oracle存储过程定义游标用动态sql
- SQL存储过程分页算法研究(支持千万级)
- oracle 在存储过程中定义动态sql
- sql 2000 分页存储过程
- SQL2005 分页存储过程
- SQL 2005 分页存储过程
- SQL分页存储过程比拚
- 分页存储过程(五)在MS SQL Server中打造更加准确,且有一点效率提升的的分页结果
- SQL分页存储过程比拚
- 一个利用sql 语句来实现分页的存储过程
- sql分页存储过程配合jquery 分页控件