1. 程式人生 > >分頁存儲過程

分頁存儲過程

asc 過程 output row set pro begin AR rom

create proc Usp_getDatabyPage
@PageSize int,
@PageIndex int,
@PageCount int output
as
begin
select * from
(
select
*,
Rn=row_number() over(order by Tid asc)
from MyTable1
)as TblMyTable1
where TblMyTable1.Rn between (@PageIndex-1)*@PageSize+1 and @PageIndex*@PageSize

declare @rdCount int
select @rdCount=count(*) from MyTable1
set @PageCount =ceiling(@rdCount/(@PageSize*1.0))
end

分頁存儲過程