Pages

Saturday, May 3, 2008

Try Catch Error handling

In SQL Server 2005 there is new era to Error handling. When i was working in Java i was thinkin when i am going to have try/catch concepts in SQL Server...Now we have it in SQL Server 2005. Try/Catch, similar to VB.Net error handling

BEGIN TRY
DECLARE @X INT
-- Divide by zero to generate Error
SET @X = 1/0
PRINT 'Command after error in TRY'
END TRY
BEGIN CATCH
PRINT 'Error Detected'
END CATCH
PRINT 'Command after TRY/CATCH blocks'

No comments: