3

When I try to use RaiseError, I get the following compilation issue

Msg 443, Level 16, State 14, Procedure ConvertSessionToCurr, Line 19 Invalid use of a side-effecting operator 'RAISERROR' within a function.

So how do we handle exception in a function/ Change it to a out param stored proc? That really sounds like a bummer!

1
  • You could have the function return NULL if an error occurs, depending upon what your application does with the function. Commented Oct 17, 2011 at 3:45

1 Answer 1

5

Options:

  • Return NULL or some sentinel value
  • Use a stored procedure
  • Make it inline code

My thought is that if you need RAISERROR in a UDF you're using it wrong...

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

2 Comments

My thought is that if you need RAISERROR in a UDF you're using it wrong...? Serious!
If you return a null or specific sentinel value, how do you pass the error code back to the caller?

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.