My Program:利用CTE將分頁資料取出-Stored Procedure篇
簡單指令參考:
with myctequery as (
select row_number() over ( ORDER BY order_code DESC ) as CTESN ,
select * from orders (nolock) )
select * from myctequery
where CTESN between 1 and 10 -- 傳入要帶入的分頁筆數
缺點是要先count一次orders的總筆數,才能決定共有幾頁。
效能在前幾頁是最好的,但隨著資料量愈大,移到愈後面的頁數效能會遞減...
沒有留言:
張貼留言