How to throw exception from SQL server 2005 function?

北城余情 提交于 2019-12-12 12:27:16

问题


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:


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



来源:https://stackoverflow.com/questions/7789100/how-to-throw-exception-from-sql-server-2005-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!