declare @pageSize int --返回一页的记录数
declare @curPage int--页号(第几页)1:第一页;2:第二页;......;-1最后一页。
declare @count int
declare @id varchar
set @pagesize=10
set @curpage=2
--最后一页
if @curpage=-1
begin
select @count=count(*) from loc_mst
if @count%@pagesize=0
set @count=@count-@pagesize+1
else
set @count=(@count/@pagesize)*@pagesize+1
end
--定位
if @curpage>0
set @count=@pagesize*(@curpage-1)+1
set rowcount @count
select @id=loc from loc_mst order by loc asc
--返回记录
set rowcount @pagesize
select * from loc_mst where loc>=@id order by loc asc
set rowcount 0
请 libin_ftsafe(子陌红尘) 帮我看看,我的下边这段sql 那里错了!
为什么 无论我把 @curpage 设置多少,都只返回第一页
declare @pageSize int --返回一页的记录数
declare @curPage int--页号(第几页)1:第一页;2:第二页;......;-1最后一页。
declare @count int
declare @id varchar
set @pagesize=10
set @curpage=2
--最后一页
if @curpage=-1
begin
set rowcount @pagesize
select @id=loc from loc_mst order by loc asc
end
--定位
if @curpage>0
begin
set @count=@pagesize*(@curpage-1)+1
set rowcount @count
select @id=loc from loc_mst order by loc asc
end
--返回记录
set rowcount @pagesize
select * from loc_mst where loc=@id order by loc asc
set rowcount 0