sql数据库常用分页存储过程

go
create proc usp_dt_managerByPage
@pagesize int=10,
@pageindex int=1,
@recordcount int output,
@pagecount int output
as
begin
    select * 
    from (select *,rn=ROW_NUMBER() over(order by id asc) from dt_manager) as t
    where t.rn between (@pageindex-1)*@pagesize+1 and @pagesize*@pageindex

    set @recordcount=(select count(*) from dt_manager)

    set @pagecount=CEILING(@recordcount*1.0/@pagesize)
end

declare @rc int,@pc int
exec usp_dt_managerByPage @pagesize=10,@pageindex=2, @recordcount=@rc output,@pagecount=@pc output
print @rc
print @pc

 

posted @ 2019-02-13 10:49  hyyweb  阅读(389)  评论(0编辑  收藏  举报