sql server 中按日期(只精确到日)选择记录的最优方式

sql server中的字段是datetime类型,而用户提出的选择条件是以天为单位的,未精确到时分秒等

经过试验,我个人觉是最优方式是 

 

   select * from tt where date between ‘2007-02-13 00:00:00.000’ and ‘2007-02-13 23:59:59.999’

    比起  … where convert(datetime, convert(varchar,date ,112), 112) = ‘2007-02-13’ 要快多了

  

   

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.