---分页存储过程 create proc usp_getpagedata @totalpage int output, --定义输出参数,页面总数 @pageindex int=1, --定义起始索引 @pagecount int=5 --定义每页数量 as select GuestId, GuestName, GuestCardId, Gender, RoomId, InTime, LeaveTime, Deposit, IsVIP, TotalMoney, IsDel from (select ROW_NUMBER() over (order by guestid) as id ,* from guest) as t where id between @pagecount*(@pageindex-1)+1 and @pagecount*@pageindex set @totalpage=(ceiling((select count(*) from guest)*1.0/@pagecount)) go ---@poagecount*(@pageindex-1)+1 @pagecount*@pageindex ---1 5*1 ---1+5 5*2 ---1+5+5 5*3 ---1+5+5+5 5*4