ISNUMERIC()

  • If I use the following statement: CASE WHEN ISNUMERIC(Field) = 1 THEN CAST(Field as Numeric) ELSE 0 END. So when the field has a numeric expression I convert it. Otherwise I put the value zero. This work as long as the field doesn't contain the values . , + and -. Because for these values the ISNUMERIC function also returns True. Does anyone know a work around in one statement? Without of course blowing the statement out of proportion.

  • CASE WHEN Field LIKE '%[^0-9]%' THEN 0 ELSE CAST(Field AS numeric) END



    --Jonathan

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply