一个字段A里面有2005/8/9这样的字符,也有乱码如1,@#$之类
我想用一条select,然后把A字段能转换为日期的都取出来,那些不能转的则跳过?
请问怎么做?
我select 加convert到那些怪字符记录的时候就停止了,说datetime和char之间转换出错云云。

解决方案 »

  1.   

    select A from t where isdate(A)=1
      

  2.   

    select *
    from 表名
    where isdate(字段名)=1
      

  3.   


    ISDATE确定输入表达式是否为有效的日期。
      

  4.   

    select case when 字段 like '[1-2][0-9][0-9][0-9]/%[0-9]/%[0-9]' then 转换 else 不转换或其它处理 end 列别表 from 表
    如果中国的%%还出现了其它情况自己看情况处理,差不多都能转过来
      

  5.   

    还是用isdate 学习了 
    case when 1=isdate(getdate()) then 转换 else 不转 end