1. 程式人生 > >SqlServer 2008R2 分頁查詢語句寫法

SqlServer 2008R2 分頁查詢語句寫法

SqlServer 2008R2分頁新寫法

--以前的寫法-必須藉助row_number()函式來獲取行的序列號
Select *
from 
(
    select 
    ROW_NUMBER() over(order by name asc)  as __tempId,
    * From (select t.*  from student t)as a
)as a
Where a.__tempId between 1 And 10
--現在的寫法-用offset 與 fetch next 來處理
select t.*
from student t
order by t.name asc
offset 0 rows fetch next 10 rows only