| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 706 人关注过本帖
标题: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
快速回复:SQL存储过成里分页问题
数据加载中...
 
   



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

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