繁体   English   中英

SQL错误IS操作数类型冲突:int与日期不兼容

[英]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');

但是我收到一条错误消息:

消息206,级别16,状态2,第13行操作数类型冲突:int与日期不兼容

按照以下格式写日期字段{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');

您应该在日期值前后加上引号 否则,它将被视为算术表达式。

因此,将您的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM