查询分析器执行下面的语句会否出错?:select datepart(yy,'2005-04-02 ')

解决方案 »

  1.   

    select count(*) from tblA where DATEPART(yy,'2005-04-02')='2005'
    可以运行
      

  2.   

    if datepart(yy,'2005-04-02 ')='2005'
    begin
    select 'a'
    end
    select 'b'
      

  3.   

    select count(*) from tblA where DATEPART(yy,replace(Dateinput,' ',''))='2005'
      

  4.   

    select count(*) from tblA where DATEPART(yy,'2005-04-02')='2005'
    可以运行
    那说明还是你表中数据的问题
      

  5.   

    --用下面的语句可以查询出表中异常的数据select Dateinput,* from tblA where isdate(Dateinput)=0
      

  6.   

    select count(*) from tblA where DATEPART(yy,replace(Dateinput,' ',''))='2005'
    也是不能运行的
      

  7.   

    To zjcxc(邹建)
    select Dateinput,* from tblA where isdate(Dateinput)=0恩 是这个原因 有会员输入的日期格式错误引起的