Just a note to myself...

 

-- Using OFFSET/ FETCH (This performance was the best.)

SELECT * FROM Vocab

ORDER BY ID

OFFSET 0 ROWS

FETCH NEXT 20 ROWS ONLY;

 

 

 

-- Using Row_Number()

SELECT * 

FROM (

     SELECT row_number() OVER (ORDER BY ID) AS RowNum,ID,word

     FROM dbo.Vocab) AS NewTable

WHERE RowNum >=10 and RowNum<=20;

 

 

 
Reference:
http://sharedderrick.blogspot.tw/2012/06/t-sql-offset-fetch.html
http://blog.xuite.net/xiaolian/blog/51944029-%5BSQL%5D+分頁之Row_Number函式用法
arrow
arrow
    全站熱搜

    以戒為師 發表在 痞客邦 留言(0) 人氣()