Syntax error converting the %ls value '%.*ls' to a column of data type %ls.
Microsoft® SQL Server™ returns this message if a character is converted to an integer. For example, these SELECT statements return error 245:
SELECT CONVERT(int, 'A')
-- Or
SELECT CAST('A' AS int)
SQL Server returns this error message because a conversion from a character value to an integer can only be done if it resembles a numeric value. For example, the character 1 (one) can be converted to an integer.
SELECT CONVERT(int, '1')
-- Or
SELECT CAST('1' AS int)
To convert a character to an integer, use the ASCII function, which returns a numerical representation of the character. For example:
SELECT CONVERT(int, ASCII('A'))
-- Or
SELECT CAST(ASCII('A') AS int)
ASCII | Data Types |
CAST and CONVERT | Errors 1 - 999 |