高效翻页存储过程CREATE PROCEDURE [Page] 
高效翻页存储过程
高效翻页存储过程
AS
高效翻页存储过程
--无优化倒序
高效翻页存储过程
declare @pageSize int   --返回一页的记录数
高效翻页存储过程
declare @CurPage int  --页号(第几页)0:第一页;-1最后一页。
高效翻页存储过程
declare @Count int
高效翻页存储过程
declare @id int
高效翻页存储过程
高效翻页存储过程
set @pageSize=10
高效翻页存储过程
set @CurPage =1
高效翻页存储过程
高效翻页存储过程
高效翻页存储过程
--定位
高效翻页存储过程
if @CurPage = -1
高效翻页存储过程
begin
高效翻页存储过程 
--最后一页
高效翻页存储过程
set rowcount @pageSize
高效翻页存储过程
select @id = ProductID from Products   order by ProductID
高效翻页存储过程
end
高效翻页存储过程
高效翻页存储过程
if @CurPage > 0
高效翻页存储过程
begin
高效翻页存储过程 
set @Count = @pageSize * (@CurPage -1+ 1
高效翻页存储过程 
set rowcount @Count
高效翻页存储过程 
select @id = ProductID from Products   order by ProductID desc
高效翻页存储过程
end
高效翻页存储过程
高效翻页存储过程
--返回记录
高效翻页存储过程
set rowcount @pageSize
高效翻页存储过程
select * from Products   where ProductID <=@id order by ProductID desc
高效翻页存储过程
高效翻页存储过程
set rowcount 0
高效翻页存储过程
GO 
高效翻页存储过程
高效翻页存储过程

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-07-01
  • 2021-06-22
  • 2021-12-17
猜你喜欢
  • 2021-06-28
  • 2022-01-20
  • 2021-12-04
  • 2022-02-05
相关资源
相似解决方案