sql server分页存储过程
时间:2021-07-01 10:21:17
帮助过:10人阅读
proc [dbo].
[messageMgr]
@pageSize int,
@pageIndex int,
@rcount bigint output
--输出查询总记录数
as
begin
declare @startRowNum int;
declare @endRowNum int;
set @startRowNum=@pageSize*(
@pageIndex - 1)
+1;
set @endRowNum=@pageIndex*@pageSize;
select * from (
SELECT ROW_NUMBER()
over(
order by a.short_message_time
desc)
as number,
*
FROM short_message_info
as a)
as a
where a.
number between @startRowNum and @endRowNum;
select @rcount=count(
number)
from (
SELECT ROW_NUMBER()
over(
order by a.short_message_time
desc)
as number,
*
FROM short_message_info
as a)
as a
end
sql server分页存储过程
标签: