if exists (select 1 from sysobjects where name ='tb')
drop table tb
go
create table tb(name varchar(10),addr varchar(10),acount int,start_date date,end_date date)
insert into tb
select '张三' ,'11-5' ,180, '2009-12-28' ,'2010-6-31' union all
select '李四' ,'11-6' ,100, '2009-12-29' ,'2010-4-10' union all
select '张三' ,'11-5' ,180, '2010-5-28' ,'2010-12-31'  
消息 241,级别 16,状态 1,第 2 行
从字符串转换日期和/或时间时,转换失败。

解决方案 »

  1.   

    时间需要标名时分秒
    格式为YYYY-MM-DD HH:MM:SS
      

  2.   


    --改成这样
    if exists (select 1 from sysobjects where name ='tb')
    drop table tb
    go
    create table tb(name varchar(10),addr varchar(10),acount int,start_date datetime,end_date datetime)
    insert into tb
    select '张三' ,'11-5' ,180, '2009-12-28' ,'2010-06-30' union all
    select '李四' ,'11-6' ,100, '2009-12-29' ,'2010-4-10' union all
    select '张三' ,'11-5' ,180, '2010-5-28' ,'2010-12-31'  
      

  3.   

    二个错误,一个是date数据类型改为datetime
    第二个是,2010年06月没有31日,所以会报错