[英]SQL ERROR IS Operand type clash: int is incompatible with date
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');
But I got an error message: 但是我收到一条错误消息:
Msg 206, Level 16, State 2, Line 13 Operand type clash: int is incompatible with date
消息206,级别16,状态2,第13行操作数类型冲突:int与日期不兼容
Write date field as following pattern {d 'yyyy-mm-dd'} 按照以下格式写日期字段{d'yyyy-mm-dd'}
Another appoint: emp_id = 1 not 01, because emp_id is int so 0 has lost. 另一个任命:emp_id = 1而不是01,因为emp_id是int,所以0丢失了。
Try this: 尝试这个:
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');
You should give quotes around date values . 您应该在日期值前后加上引号 。 Other wise it will be treated as an arithmetic expression.
否则,它将被视为算术表达式。
So change your insert
query to 因此,将您的
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');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.