标题:SQL存储过成里分页问题
取消只看楼主
huojian
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-11-5
 问题点数:0 回复次数:0 
SQL存储过成里分页问题
/////////////////分页的代码/////////////
use pubs
go
create proc get_titles_info1
@pageSize int,
@currentPage int,
@totalPage int output
as
declare @strQuery as varchar(1000)
declare @rowCount as int
select @rowCount=count(title_id)from titles
set @totalPage=CEILING(CAST(@rowCount AS FLOAT)/CAST(@pageSize AS FLOAT))
if @currentPage>1
begin
if @currentPage>@totalPage
begin
set @currentPage=@totalPage
end
set @strQuery='select top'+cast(@pageSize as varchar
(10))+'* from titles
where title_id not in(select top '+cast(@pageSize*(@currentPage-1)as varchar(10))+'title_id from titles order by title_id)
order by title_id'
end
else
begin
set @strQuery='select top '+cast(@pageSize as varchar(10))+'
* from userinfo order by userID'
end
exec(@strQuery)
go
一个存储过程里分页的,我想运行这个存储过程怎么运行,我用如下运行怎么说我错误
declare @total int
exec get_titles_info 6,2, @total output
print'总页数为:'+cast(@total as varchar(6))+'页
搜索更多相关主题的帖子: SQL int totalPage currentPage FLOAT 
2007-11-24 14:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-188068-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.319105 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved