Error 245

Troubleshooting SQL Server

Troubleshooting

Error 245

Severity Level 16
Message Text

Syntax error converting the %ls value '%.*ls' to a column of data type %ls.

Explanation

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)
Action

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)

See Also

ASCII

CAST and CONVERT

Data Types

Errors 1 - 999