简体   繁体   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');

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.

相关问题 SQL 服务器“操作数类型冲突:int 与日期不兼容”错误 - SQL Server 'Operand type clash: int is incompatible with date' error SQL 服务器错误操作数类型冲突:int 与日期不兼容 - SQL Server error Operand type clash: int is incompatible with date 操作数类型clash int与sql server中的日期不兼容 - operand type clash int is incompatible with date in sql server SQL Server 2012(触发器)操作数类型冲突:int与日期不兼容 - SQL Server 2012 (triggers) Operand type clash: int is incompatible with date SQL Server Operand类型冲突:日期与int不兼容 - Sql Server Operand type clash: date is incompatible with int SQL语句不起作用 - “操作数类型冲突:日期与int不兼容” - SQL statement not working - "Operand type clash: date is incompatible with int' 如何修复错误 - 操作数类型冲突:日期与 int 不兼容 - How to fix the error - Operand type clash: date is incompatible with int 操作数类型冲突:日期与int不兼容? - Operand type clash: date is incompatible with int? 操作数类型冲突:日期与sql server中的smallint错误不兼容 - Operand type clash: date is incompatible with smallint error in sql server 使用日期“'操作数类型冲突:日期与int不兼容'用SQL查询填充Datagrid - Fill Datagrid with Sql Query using Date " 'Operand type clash: date is incompatible with int''
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM