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