RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
一个利用CTE递归在存储过程中实现真分页的代码示例

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

“真诚服务,让网络创造价值”是我们的服务理念,创新互联公司团队10多年如一日始终坚持在网站建设领域,为客户提供优质服。不管你处于什么行业,助你轻松跨入“互联网+”时代,PC网站+手机网站+公众号+小程序制作

 
 
 
  1. SET ANSI_NULLS ON    
  2.  
  3. GO    
  4.  
  5. SET QUOTED_IDENTIFIER ON    
  6.  
  7. GO    
  8.  
  9. ALTER proc [dbo].[BIReport_GetAllReport_Page]    
  10.  
  11. @currentpage int,--当前页码     
  12.  
  13. @pagesize int  --每页显示的条数     
  14.  
  15. as      
  16.  
  17. declare @beginindex   int    
  18.  
  19. declare @endindex  int    
  20.  
  21. begin    
  22.  
  23. select @beginindex=(@currentpage-1)*@pagesize    
  24.  
  25. select @endindex=@beginindex+@pagesize    
  26.  
  27. end     
  28.  
  29. begin    
  30.  
  31. With X as   --CTE递归          
  32.  
  33. (        
  34.  
  35. Select *, row_number() over(order by ReportId) as rowNum    
  36.  
  37. From BIReport    
  38.  
  39. )    
  40.  
  41. select * from X     
  42.  
  43. where rowNum between @beginindex+1 and @endindex    
  44.  
  45. end 

 

以上就是利用CTE递归在存储过程中实现真分页的代码,希望通过阅读上面的代码,能够带给您一些收获吧。


分享标题:一个利用CTE递归在存储过程中实现真分页的代码示例
网站URL:http://www.jxjierui.cn/article/dhjspec.html