一個(gè)利用CTE遞歸在存儲(chǔ)過程中實(shí)現(xiàn)真分頁的代碼示例
作者:wangdingbang
本文主要給出了一個(gè)利用CTE遞歸在存儲(chǔ)過程中實(shí)現(xiàn)真分頁的代碼示例,供初學(xué)者參考,希望能夠?qū)δ兴鶐椭?/div>
利用CTE遞歸在存儲(chǔ)過程中實(shí)現(xiàn)真分頁的技術(shù)還是比較簡單的,本文我們給出了一個(gè)利用CTE遞歸在存儲(chǔ)過程中實(shí)現(xiàn)真分頁的代碼示例,對(duì)于初學(xué)者來說可以套用下面的代碼,代碼示例如下:
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- ALTER proc [dbo].[BIReport_GetAllReport_Page]
- @currentpage int,--當(dāng)前頁碼
- @pagesize int --每頁顯示的條數(shù)
- 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遞歸在存儲(chǔ)過程中實(shí)現(xiàn)真分頁的代碼,希望通過閱讀上面的代碼,能夠帶給您一些收獲吧。
【編輯推薦】
責(zé)任編輯:趙鵬
來源:
CSDN博客


相關(guān)推薦




