分页存储过程2000

浏览:30日期:2023-06-29
CREATE procedure GetUsers(@pagesize int,@pageindex int,@docount bit)asset nocount onif(@docount=1)select count(userId) from Userselsebegindeclare @indextable table(id int identity(1,1),nid int)declare @PageLowerBound intdeclare @PageUpperBound intset @PageLowerBound=(@pageindex-1)*@pagesizeset @PageUpperBound=@PageLowerBound+@pagesizeset rowcount @PageUpperBoundinsert into @indextable(nid) select userId from Users order by userName descselect O.* from Users O,@indextable t where O.userId=t.nidand t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.idendset nocount offGO
相关文章: