一个简单的分页存储过程
2006-12-11 19:38
381 查看
create proc Pager
@PageIndex int,
@PageSize int,
@PageCount int out,
@RecordCount int out
as
select @RecordCount= count(*) from film_type
set @PageCount = CEILING(@RecordCount * 1.0 / @PageSize)
declare @topCount int
SET @topCount = @RecordCount - @PageSize * @PageIndex
DECLARE @SQLSTR NVARCHAR(1000)
if @PageIndex=0 or @RecordCount <=0
begin
set @SQLSTR=N'select top '+str(@PageSize) +' film_id,film_name from film_type order by film_id desc'
end
else
begin
if @PageIndex=@PageCount-1
begin
set @SQLSTR=N'select * from (select top '+str(@topCount)+' film_id,film_name from film_type order by film_id asc)T order by film_id desc'
end
else
begin
set @SQLSTR=N'select top '+str(@PageSize)+' * from (select top '+str(@topCount)+' film_id,film_name from film_type order by film_id asc)T order by film_id desc '
end
end
print @SQLSTR
EXEC (@SQLSTR)
drop proc Pager
declare @pageCount int
declare @recordCount int
exec Pager 0,5,@pageCount out,@recordCount out
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。
@PageIndex int,
@PageSize int,
@PageCount int out,
@RecordCount int out
as
select @RecordCount= count(*) from film_type
set @PageCount = CEILING(@RecordCount * 1.0 / @PageSize)
declare @topCount int
SET @topCount = @RecordCount - @PageSize * @PageIndex
DECLARE @SQLSTR NVARCHAR(1000)
if @PageIndex=0 or @RecordCount <=0
begin
set @SQLSTR=N'select top '+str(@PageSize) +' film_id,film_name from film_type order by film_id desc'
end
else
begin
if @PageIndex=@PageCount-1
begin
set @SQLSTR=N'select * from (select top '+str(@topCount)+' film_id,film_name from film_type order by film_id asc)T order by film_id desc'
end
else
begin
set @SQLSTR=N'select top '+str(@PageSize)+' * from (select top '+str(@topCount)+' film_id,film_name from film_type order by film_id asc)T order by film_id desc '
end
end
print @SQLSTR
EXEC (@SQLSTR)
drop proc Pager
declare @pageCount int
declare @recordCount int
exec Pager 0,5,@pageCount out,@recordCount out
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。
相关文章推荐
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的存储过程数据分页
- 一个简单的oracle分页存储过程的实现和调用
- 使用数据库存储过程完成一个简单分页
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的存储过程数据分页
- 一个简单的SQl存储过程分页
- 一个简单的ASP调用存储过程分页
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的存储过程数据分页
- 【老码农怀旧】一个简单好用的分页存储过程
- 分页存储过程--一个简单的SQL存储过程
- 一个简单的oracle分页存储过程的实现和调用
- 一个简单的sql存储过程
- SQL____一个简单的存储过程
- 一个高效的数据分页的存储过程 可以轻松应付百万数据
- 详述在设有快表的请求分页存储管理系统中,一个虚地址转换成物理内存地址的过程。