34,575
社区成员
发帖
与我相关
我的任务
分享
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 行
从字符串转换日期和/或时间时,转换失败。
--改成这样
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'