SELECT  
vP.BranchCD
,vP.ProductCD
,vP.CostPrice
,vP.OrderStartDate
FROM ABCD vP
WHERE 
1=1
AND vP.modified>=2009/12/29------此字段是时间类型-----------------------------------------------------
时间类型输入错误,本以为会抱错,结果是把表中数据全部搜索出来这是为什么呢?

解决方案 »

  1.   

    2009/12/29 这里算是除法了,然后得出的int值再转成datetime
      

  2.   

    select cast(cast(2009/12/29 as int) as datetime)1900-01-06 00:00:00.000
      

  3.   

    AND vP.modified>=2009/12/29------此字段是时间类型 大大说得很清楚了,没引号是当作运算符来算了
      

  4.   

    vP.modified 字段是时间类型比较的对象 2009/12/29  可以不是时间类型吗
      

  5.   

    可以是能隐式转换成datetime的数据类型
      

  6.   

    declare @时间 smalldatetime
    set @时间=2009/12/29
    print @时间
      

  7.   

    不会报错,但是得不到结果.
    create table tb(dt datetime)
    insert into tb values(convert(varchar(10),getdate(),120))
    insert into tb values(getdate())
    insert into tb values(getdate())
    insert into tb values(getdate())
    insert into tb values(getdate())
    insert into tb values(getdate())
    goselect * from tb
    /*
    dt                                                     
    ------------------------------------------------------ 
    2009-12-30 00:00:00.000
    2009-12-30 22:08:21.187
    2009-12-30 22:08:21.187
    2009-12-30 22:08:21.187
    2009-12-30 22:08:21.187
    2009-12-30 22:08:21.187(所影响的行数为 6 行)
    */select * from tb where dt = 2009/12/30
    /*
    dt                                                     
    ------------------------------------------------------ (所影响的行数为 0 行)
    */select * from tb where dt = 2009-12-30
    /*
    dt                                                     
    ------------------------------------------------------ (所影响的行数为 0 行)
    */drop table tb