分页存储过程

create proc proc_Page
(
@pageIndex int,
@pageSize int,
@Count int output
)
as
begin
 declare @start int = (@pageIndex-1)*@pageSize +1
 declare @end int = @pageIndex * @pageSize
 select @Count = count(*) from UserInfo
 select * from
 (select ROW_NUMBER() over (order by UID) as No,* from UserInfo)
  T where t.No between @start and @end
end
drop proc proc_Page

declare @count int
exec proc_Page 1,3,@count output
select @count

 

posted @ 2020-02-17 17:56  zhengyiwei  阅读(102)  评论(0)    收藏  举报