十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
利用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递归在存储过程中实现真分页的代码,希望通过阅读上面的代码,能够带给您一些收获吧。