I am getting an error
Error converting data type nvarchar to float
in this part of my stored procedure:
SELECT
CAST(RTRIM(Value) AS FLOAT)
FROM
table_1
WHERE
ISNUMERIC(RTRIM(Value)) = 1
AND RTRIM(Value) NOT LIKE '%[^0-9.]%'
I tried to track down the value that would have caused this but was unable to do so and now the procedure runs successfully so I don't have the ability to track down the problematic value format.
If someone can suggest a way I would like to know what value could have pass through the 2 checks we have.
SELECT case when Value <> '' then cast(cast(value as nvarchar(50)) as float) ELSE 0.0to find problem value - user3127554ISNUMERIC('-') = 1, butCAST('-' AS FLOAT)is an error. Then there's the fact thatWHEREdoesn't always protect you, although that should not be in effect for a trivialSELECTlike this.TRY_CASTandTRY_CONVERTare your friends, if you have them;CASEoften bails you out as well (but is unfortunately still not foolproof in the face of some aggressive optimizations). - Jeroen Mostert