Home » SQL Server Error : 245, Severity: 16. Conversion failed when converting the %l

SQL Server Error : 245, Severity: 16. Conversion failed when converting the %l

SQL Server Error : 245 Details


SQL Server Error: 245
Severity: 16
Event Logged or not: No
Description:
Conversion failed when converting the %ls value ‘%.*ls’ to data type %ls.
Severity 16 Description:
Indicates general errors that can be corrected by the user.

SQL SERVER – Error: Msg 245 – Conversion failed when converting the varchar value ‘AllisWell’ to data type int

Solution for Resolving SQL Server Error 245

It’s critical that all return values be of the same data type when converting the data type. We’d wind up with conversion issues if we didn’t do this.

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'SQlAuthority' to data type int.

The column to which we are converting is an integer, but the value “AllisWell” is a string, so it can not be converted and thus the error SQL Server Error 245. Data Type Precedence is due to the datatype precedence rule. SQL Server is attempting to convert the data type String to Integer implicitly.

Make sure a integer values conversion possible values are input for any conversion functions. Otherwise this error message says that its not possible to convert the datatype.

Reading sql server error log location from SQL Query

Identifying SQL Server Error Log File used by SQL Server Database Engine can be done by reading SQL Server Error Logs. DBA can execute the XP_READERRORLOG extended stored procedure to read the SQL Server Error Log and search for its location used by the instance of SQL Server.

USE master
Go
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file', NULL, NULL, N'asc'
Go

The parameters for XP_READERRRORLOG are:
1. Value of error log file we would like to read. values are 0 = current, 1 = last one before current, 2 = second last before current etc…
2. Log file type:- 1 or NULL = error log, 2 = SQL Agent log

For other ways to read and find error log location please our artcile https://sqlserver-dba.co.uk/error-log/sql-server-identify-location-of-the-sql-server-error-log-file.html

SQL Server Error Code and solution summary


SQL Server Error: 245
Severity: 16
Event Logged or not: No
Description:
Conversion failed when converting the %ls value ‘%.*ls’ to data type %ls.

Make sure the input values which are tried for conversion to integer are not string values which will throw this error.

Leave a Reply

Your email address will not be published. Required fields are marked *