分页存储过程

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

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐