我正在寻找一种在不使用经典 try catch 的情况下捕获错误的方法,因为此代码不适用于我的 SQL 版本(2005)
BEGIN TRY
SELECT 1/0;
END TRY
BEGIN CATCH
EXECUTE usp_GetErrorInfo;
END CATCH;
错误:
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'END'.
任何解决方法?还是我做错了什么?