0

The values are stored in varchar.I try to check if the values are numeric then convert to decimal, if not then return the original value. The first case itself work fine if I comment out the second part.

CASE WHEN ISNUMERIC(Num) = 1 THEN CONVERT(DECIMAL(7,2),CONVERT(FLOAT, Num))
     WHEN ISNUMERIC(Num) = 0 THEN Num END,
3
  • 1
    The result of that CASE expression can be different data types, that can't be Commented May 13, 2015 at 17:42
  • doesn't the first one return an error on isnumeri? Commented May 13, 2015 at 17:44
  • To xQbert, I accidently delete the c... Commented May 13, 2015 at 18:16

1 Answer 1

1

The problem is that you are returning different types. You need convert the return values to the same type for safe query. Either convert the decimal back to varchar, or return 0 when num is not a number.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.