, ( " (" none ")) @timus2001 answer:
WHERE
CASE
WHEN Field NOT LIKE '%[^0-9]%' AND LEN(Field) <= 38
THEN CAST(CAST(Field AS decimal(38, 0)) AS varchar(38))
ELSE Field
END = '555'
A length test is necessary if the value can be too large to convert to the longest 1 possible numeric type. You can simply use the condition LEN(Field) = 3instead LEN(Field) <= 38, but then you have to remember to change this part if the requirement '555'has changed to something else. Be that as it may, you will need to replace the string '555'if necessary (and remember that it should never exceed 38 characters).
1 in terms of decimal digits or scales.
source
share