Sql server 2005带来的分页便利

王朝mssql·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

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

===========================================

如果里面的这个表cs_threads数据量超大,比如,几亿条记录,那这个方法应该是有问题的

因为,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

这个语句是把select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads它全部取出来,然后在SQL的外面进行分页的,没在SQL2005上测试过,因为原先在ORACLE上这样的写法是不好的,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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航