Skip to main content

Posts

Showing posts with the label Error Handling in SQL Server Stored Procedure using TRY/CATCH

Exception Handling using Try Catch in SQL Server Stored Procedures

In SQL- Transact, The   TRY CATCH   are catches all errors and store in the   @ERRORS   variable and raise the errors using the   RAISERROR (). Following functions are used in CATCH block, 1.       ERROR_NUMBER (): Will return error number. 2.       ERROR_SEVERITY ():Will return severity level. 3.       ERROR_STATE ():Will return state number. 4.       ERROR_LINE ():Will return error line number. 5.       ERROR_PROCEDURE ():Will return stored procedure name that occurred the error. 6.       ERROR_MESSAGE ():Will return full message text of the error. USE OF TRY CATCH IN SQL SERVER BEGIN TRY     YOUR CODE HEARE END TRY BEGIN CATCH     YOURE CODE TO HANDLE ERRORS END CATCH Example for Exception/Error Handling in Stored ...