NSN
NSN

Reputation: 750

How to throw exception from SQL server 2005 function?

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!

Upvotes: 3

Views: 2533

Answers (1)

gbn
gbn

Reputation: 432180

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...

Upvotes: 5

Related Questions