I am using SQL Server 2008. I have tried to execute the following:
BEGIN TRY
SELECT 1/0;
END TRY
BEGIN CATCH
PRINT 'ERROR'
END CATCH;
But I am getting the following error:
>Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'END'.
Can any one tell me how execute try catch in SQL Server?