On Transact SQL language the Msg 242 Level 16 - The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. This means that the format date is incorrect.
Msg 242 Level 16 Example:
Create table
USE model;
GO
create table Test
(id int not null,
name varchar(500) not null,
entry_date datetime not null
);
GO
Invalid statement:
USE model;
GO
insert into test(id,name,entry_date)
values(1,'mssql','29-12-2017');
GO
Message |
---|
Msg 242, Level 16, State 3, Line 3 |
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. |
Correct statement:
USE model;
GO
insert into test(id,name,entry_date)
values(1,'mssql',getdate());
insert into test(id,name,entry_date)
values(2,'sql server',sysdatetime());
GO
Other error messages:
- Is not a defined system type
- Conversion failed when converting the varchar value
- Unknown object type used in a CREATE, DROP, or ALTER statement
- Cannot insert the value NULL into column
- Cannot insert explicit value for identity column in table
- The INSERT statement conflicted with the FOREIGN KEY constraint
- The DELETE statement conflicted with the REFERENCE constraint