Error Converting Data Type Varchar To Numeric Sql Server

[Solved] Error Converting Data Type Varchar To Numeric Sql Server | Lua - Code Explorer | yomemimo.com
Question : error converting data type varchar to numeric. sql server

Answered by : abdullrhman-elhelw

/*
To fix this, you’d need to make sure you provide a value that SQL Server can convert.
If you’re passing a column, check that you’ve got the right column. Same if you’re passing a variable – check that it’s the right variable.
Bear in mind that this might not happen in all cases of trying to convert a string to decimal, because some string values can be converted.
For example, the following conversion succeeds:
*/
select select cast('10' as decimal(5,0)); /* output	10.00 */
/*
If you don’t mind the conversion failing, but you just don’t want it to return an error, try the TRY_CAST() or TRY_CONVERT() functions.
Rather than return an error, these functions return NULL when the value can’t be converted.
*/
Example:
SELECT TRY_CAST('Ten' AS DECIMAL(5,2)); /* output	null */

Source : https://database.guide/fix-msg-8114-error-converting-data-type-varchar-to-numeric-in-sql-server/ | Last Update : Wed, 01 Mar 23

Answers related to error converting data type varchar to numeric sql server

Code Explorer Popular Question For Lua