On Transact SQL language the Msg 245 Level 16 - Conversion failed when converting the varchar value means that you insert varchar values into an int column.
Msg 245 Level 16 Example:
We have the table TEST:
USE model;
GO
CREATE TABLE TEST(
ID INT NOT NULL PRIMARY KEY,
NAME VARCHAR(10) NOT NULL );
GO
Invalid insert:
USE model;
GO
INSERT INTO TEST(id, name) VALUES ('abc', 'Olivia');
GO
Message |
---|
Msg 245, Level 16, State 1, Line 1 |
Conversion failed when converting the varchar value 'abc' to data type int. |
Correct insert:
USE model;
GO
INSERT INTO TEST(id, name) VALUES (1, 'Olivia');
GO
Message |
---|
(1 row(s) affected) |
Other error messages:
- Conversion failed when converting date and/or time from character string
- Is not a defined system type
- 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