Introduction:
Here
I will explain how to handle exceptions in SQL
Server
or exception handling in SQL
Server
for stored procedure by using try catch or error handling in SQL Server.
Description:
In previous articles I explained Pass table as parameter to stored procedure in SQL Server, Difference between joins in SQL Server, Convert rows to columns in SQL Server, SQL Query to get duplicate records count and many articles relating to SQL Server, jQuery, JavaScript. Now I will explain how to handle exceptions in SQL Server.
In previous articles I explained Pass table as parameter to stored procedure in SQL Server, Difference between joins in SQL Server, Convert rows to columns in SQL Server, SQL Query to get duplicate records count and many articles relating to SQL Server, jQuery, JavaScript. Now I will explain how to handle exceptions in SQL Server.
To
handle exceptions in
SQL
Server we can use TRY…… CATCH blocks. To use TRY……
CATCH blocks in stored procedure we need to write the query like as
shown below