查询一个表,含有一个datetime型字段时出现了以下错误,如果找到这个行呢?
服务器: 消息 542,级别 16,状态 1,行 1
遇到了无效的 datetime 值。该值超过了 9999 年。

解决方案 »

  1.   

    select *
    from tb
    where left(convert(varchar(10),你的字段,120),4)>9999
      

  2.   

    var tmpResult = from c in youDateContext.youTable where youClum.year > 9999
      

  3.   


    select *
    from tb
    where year(字段)>=9999
      

  4.   


    select * from mytable where year(cast(mydatacol as datetime2))>9999
      

  5.   

    你试试能插入大于9999年份的日期型数据吗?能插进去也算本事啊.这个问题是数据库出现一致性错误,DBCC修复没有成功.