0
I am trying to convert data from a column in NVARCHAR(255) to DECIMAL(10,2), however, all the ways I tried always gives the same error Error Converting data type nvarchar to Numeric. I created another column of type DECIMAL(10,2) to transfer the data from the column of type NVARCHAR(255), but even with CONVERT or CAST also does not convert. Follow the code below:
SELECT CASE
WHEN Isnumeric(salario) 0 THEN CONVERT(NVARCHAR(255),
CONVERT(DECIMAL(10, 2), salario))
ELSE salario
END AS [SALÁRIO]
FROM dbo.rendimentos
How is the format of this string in the database? maybe it is in an invalid format to convert to decimal. Something else. may be giving error because the column is null or empty string.
– Rodrigo K.B
The salary column is set to allow Nulls values, but has no null value. Using the ISNUMERIC() function, all the data in this column return the value 1, that is, all are numerical. Even so, it returns the conversion error.
– Kelly Soares
@Kellysoares What is the decimal separator: semicolon?
– José Diz