Why is TRY-CATCH block not allowed inside UDFs?

前端 未结 4 939
死守一世寂寞
死守一世寂寞 2021-02-11 21:54

Why doesn\'t SQL Server support TRY-CATCH blocks inside UDFs?

If we\'re talking about scalar UDFs, which are mostly used for calculations and conversations, this block s

4条回答
  •  名媛妹妹
    2021-02-11 22:24

    With SQLServer 2012, you can try exec sp_your_procedure_with_try_catch, it worked for me.

    Actually several of my triggers have the logics in one key SP. I didn't know try-catch is not allowed in UDF, until I tried to rewrite some of them without the SP.

提交回复
热议问题