利用CTE递归在存储过程中实现真分页的技术还是比较简单的,本文我们给出了一个利用CTE递归在存储过程中实现真分页的代码示例,对于初学者来说可以套用下面的代码,代码示例如下:

“真诚服务,让网络创造价值”是我们的服务理念,创新互联公司团队10多年如一日始终坚持在网站建设领域,为客户提供优质服。不管你处于什么行业,助你轻松跨入“互联网+”时代,PC网站+手机网站+公众号+小程序制作。
- SET ANSI_NULLS ON
 - GO
 - SET QUOTED_IDENTIFIER ON
 - GO
 - ALTER proc [dbo].[BIReport_GetAllReport_Page]
 - @currentpage int,--当前页码
 - @pagesize int --每页显示的条数
 - as
 - declare @beginindex int
 - declare @endindex int
 - begin
 - select @beginindex=(@currentpage-1)*@pagesize
 - select @endindex=@beginindex+@pagesize
 - end
 - begin
 - With X as --CTE递归
 - (
 - Select *, row_number() over(order by ReportId) as rowNum
 - From BIReport
 - )
 - select * from X
 - where rowNum between @beginindex+1 and @endindex
 - end
 
以上就是利用CTE递归在存储过程中实现真分页的代码,希望通过阅读上面的代码,能够带给您一些收获吧。
Copyright © 2009-2022 www.wtcwzsj.com 青羊区广皓图文设计工作室(个体工商户) 版权所有 蜀ICP备19037934号