首页 > 开发 > 综合 > 正文

分页存储过程2000

2024-07-21 02:31:52
字体:
来源:转载
供稿:网友
CREATE PRocedure GetUsers
(@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
if(@docount=1)
select count(userId) from Users
else
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select userId from Users order by userName desc
select O.* from Users O,@indextable t where O.userId=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
end
set nocount off
GO
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表