![](/img/trans.png)
[英]SQL Server 'Operand type clash: int is incompatible with date' error
[英]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.