请教 在 sql2000中, 日期'2009-06-01' 和 '2009-6-1' 相同吗?select 1 from sysfiles where '2009-06-01' = '2009-06-01'请高人指点.

解决方案 »

  1.   

     
    select 1 from sysfiles where '2009-06-01' = '2009-6-1' 
    这肯定是不成立的。
    因为是两个字符串。
    但是作为日期他们是等的。也就是select 1 from sysfiles where cast('2009-06-01' as smalldatetime) = cast('2009-6-1' as smalldatetime)这是OK
      

  2.   

    select 1 from sysfiles where '2009-06-01' = '2009-6-1' 显然不正确,因为是字符串比较
    select 1 from sysfiles where '2009-06-01' = '2009-06-01' 正确!!