使用这个存储过程可以实现分页的,新手可以看看哦!
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