--数据库分页存储过程 create proc up_GetPagedArticel @pageIndex int =1, @author int, @pageSize int, @isDel int =0, @rowCount int output, @pageCount int output as begin --1.总行数 select @rowCount=COUNT(AId) from BlogArticle where AAuthor=@author and AIsDel=@isDel --2.根据总行数算出总页数 set @pageCount=ceiling(@rowCount*1.0/@pageSize*1.0) --3根据页码查询文章 select * from (select ROW_NUMBER() over(order by aid) as rowNum,* from BlogArticle where AAuthor=@author and AIsDel=@isDel) as t where t.rowNum >(@pageIndex-1)*@pageSize and t.rowNum<=@pageIndex*@pageSize end
--数据库分页存储过程
create proc up_GetPagedArticel
@pageIndex int =1,
@author int,
@pageSize int,
@isDel int =0,
@rowCount int output,
@pageCount int output
as
begin
--1.总行数
select @rowCount=COUNT(AId) from BlogArticle where AAuthor=@author and AIsDel=@isDel
--2.根据总行数算出总页数
set @pageCount=ceiling(@rowCount*1.0/@pageSize*1.0)
--3根据页码查询文章
select * from
(select ROW_NUMBER() over(order by aid) as rowNum,* from BlogArticle where AAuthor=@author and AIsDel=@isDel)
as t where t.rowNum >(@pageIndex-1)*@pageSize and t.rowNum<=@pageIndex*@pageSize
end