Articles → SQL SERVER → Exception Handling In SQL Servers

Exception Handling In SQL Servers






Try Catch Throw


  1. Try → In the try block, we write the code that may cause an exception
  2. Catch → In the catch block, we write the code to catch the exception
  3. Throw → The throw is used to rethrow the exception

Example


Begin Try
 select 7/0
End Try
Begin Catch
 throw
End Catch



Output


Picture showing the output of exception handling in SQL server
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, February 8, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250