使用這個存儲過程可以實現分頁的,新手可以看看哦!
create PRoc proPage(@pageid int ,@pagesize int)
as
begin
if (@pageid=1)
begin
set rowcount @pagesize
select * from test order by id
end
else
begin
declare @no1 int
declare @num int
select @num=@pagesize*(@pageid-1)
set rowcount @num
select @no1=id from test order by id
declare @no2 int
select @num=@pagesize*@pageid
set rowcount @num
select @no2=id from test order by id
set rowcount 0
select * from test where id>@no1 and id<=@no2
end
end