一个简单的用存储过程分页
2006-05-17 10:34:19 来源:WEB开发网核心提示:使用这个存储过程可以实现分页的,新手可以看看哦!create PRoc proPage(@pageid int ,@pagesize int)asbeginif (@pageid=1)begin set rowcount @pagesize select * from test order by idendelsebe
使用这个存储过程可以实现分页的,新手可以看看哦!
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
[]
赞助商链接