如何获取执行原生sql的错误信息?

如何获取执行原生sql的错误信息


墨色风雨
浏览 960回答 1
1回答

拉风的咖菲猫

获取代码如下:BEGIN TRYSELECT 3 / 0END TRYBEGIN CATCHDECLARE @errornumber INTDECLARE @errorseverity INTDECLARE @errorstate INTDECLARE @errormessage NVARCHAR(4000)SELECT@errornumber = ERROR_NUMBER() ,@errorseverity = ERROR_SEVERITY() ,@errorstate = ERROR_STATE() ,@errormessage = ERROR_MESSAGE()SELECT @errornumber ,@errorseverity ,@errorstate ,@errormessageRAISERROR (@errormessage, -- Message text,@errorseverity, -- Severity,@errorstate, -- State,@errornumber);END CATCH
打开App,查看更多内容
随时随地看视频慕课网APP