Sql server 2005帶來(lái)的分頁(yè)便利
select threadid from (select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads) as T where T.Pos > 100000 and T.Pos < 100030
===========================================
如果里面的這個(gè)表cs_threads數(shù)據(jù)量超大,比如,幾億條記錄,那這個(gè)方法應(yīng)該是有問(wèn)題的
因?yàn)椋瑂elect threadid from ( select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads ) as T where T.Pos > 100000 and T.Pos < 100030 這個(gè)語(yǔ)句是把select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads它全部取出來(lái),然后在SQL的外面進(jìn)行分頁(yè)的,沒(méi)在SQL2005上測(cè)試過(guò),因?yàn)樵仍贠RACLE上這樣的寫法是不好的,ORACLE中這樣寫比較好:select threadid from ( select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads a where a.pos<100030 ) as T where T.Pos > 100000
出處:blog.joycode.com/dotey/archive/2006/01/16/70493.aspx
