Another TRY/CATCH : Try catch « Transact SQL « SQL Server / T-SQL Tutorial






6> BEGIN TRY
7>     SELECT 1/0 AS DivideByZero
8>     SELECT 1 AS NoError
9> END TRY
10> BEGIN CATCH
11>     SELECT 'Exception Caught!' AS CatchMessage
12> END CATCH
13> GO
DivideByZero
------------

(0 rows affected)
CatchMessage
-----------------
Exception Caught!

(1 rows affected)
1>
2>








20.23.Try catch
20.23.1.Error Handling in SQL Server 2005
20.23.2.Error Handling with TRY...CATCH
20.23.3.try...catch Demo
20.23.4.Basic TRY/CATCH
20.23.5.Another TRY/CATCH
20.23.6.Nesting TRY...CATCH Calls
20.23.7.Applying TRY...CATCH Error Handling Without Recoding a Stored Procedure