CREATE TABLE prime_emp (
emp_id INT not null,
first_name VARCHAR(14) not null,
last_name VARCHAR(14) not null,
birth_date DATE not null,
father_name VARCHAR (14) not null,
mather_name VARCHAR (14),
joing_date DATE not null,
departmen VARCHAR(14) not null,
Primary key (emp_id)
)
select * from prime_emp
insert into prime_emp
(emp_id,first_name,last_name,birth_date,father_name,mather_name, joing_date,departmen)
values(01,'Ashish','Soni',15-07-1990,'Suman','Usha',28-10-2013,'Media');
但是我收到了一条错误消息:
Msg 206,Level 16,State 2,Line 13 操作数类型冲突:int与日期不兼容
答案 0 :(得分:0)
将日期字段写为以下模式{d'yyyy-mm-dd'}
另一个指定:emp_id = 1而不是01,因为emp_id是int所以0已经丢失。
试试这个:
insert into prime_emp
(emp_id,first_name,last_name,birth_date,father_name,mather_name, joing_date, departmen)
values
(1,'Ashish','Soni',{d '1990-07-15'},'Suman','Usha',{d '2013-10-28'},'Media');
答案 1 :(得分:0)
您应在日期值周围添加引号。其他明智的将被视为一个 算术表达式。
因此,请将insert
查询更改为
insert into prime_emp
(emp_id,first_name,last_name,birth_date,father_name,mather_name, joing_date,departmen)
values(01,'Ashish','Soni','15-07-1990','Suman','Usha','28-10-2013','Media');