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))+'页