如我想得到某到2005年里的数据有那几种方法?那个效率高一些?

解决方案 »

  1.   

    select * from 表 where rq>='2005-01-01' and rq<'2006-01-01'
      

  2.   

    select * from 表 where year(日期)=2005select * from 表 where datepart(year,日期)=2005
      

  3.   

    select datename(yy,getdate())
    --
    select * from 表 where rq>='2005-01-01' and rq<'2006-01-01'的效率最高
    避免在条件中对字段做计算或使用函数
      

  4.   

    liangpei2008(我爱世界杯) 有道理。
      

  5.   

    select * from 表 where rq BETWEEN '2005-01-01'  AND '2006-01-01'