i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is TRY/CATCH block in T-SQL?
02-16-2013, 05:39 PM
Post: #1
What is TRY/CATCH block in T-SQL?
Quote:When an error condition is detected in a Transact-SQL statement contained in a TRY block, control is passed to a CATCH block where it can be processed.

Example
Code:
BEGIN TRY
DECLARE @Num INT
-- generate infinity exception
SET @Num = 5/0
END TRY
BEGIN CATCH
PRINT 'Exception Occured'
END CATCH

The result of the above code will be:
Quote:Exception Occured






View Asad Ali's profile on LinkedIn

Quote




User(s) browsing this thread: 1 Guest(s)