SOLVED

HANDLING ERRORS IN SQL PROCEDURES

%3CLINGO-SUB%20id%3D%22lingo-sub-3203403%22%20slang%3D%22en-US%22%3EHANDLING%20ERRORS%20IN%20SQL%20PROCEDURES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3203403%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EHow%20can%20I%20catch%20an%20error%20in%20a%20procedure%20and%20the%20procedure%20will%20continue%20running%20to%20the%20end%20without%20failing.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EUsually%20a%20procedure%20fails%20when%20it%20encounters%20an%20error%20during%20the%20execution%20of%20the%20procedure.%20but%20there%20is%20a%20way%20that%20you%20can%20add%20a%20condition%20to%20the%20procedure%20to%20write%20the%20error%20somewhere%20and%20the%20procedure%20will%20continue%20to%20the%20end%20without%20aborting%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3212647%22%20slang%3D%22en-US%22%3ERe%3A%20HANDLING%20ERRORS%20IN%20SQL%20PROCEDURES%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3212647%22%20slang%3D%22en-US%22%3E%3CP%3EDepending%20on%20the%20error%20servity%20you%20can%20handle%20errors%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Flanguage-elements%2Ftry-catch-transact-sql%3Fview%3Dsql-server-ver15%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ETRY...CATCH%20(Transact-SQL)%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

How can I catch an error in a procedure and the procedure will continue running to the end without failing.

Usually a procedure fails when it encounters an error during the execution of the procedure. but there is a way that you can add a condition to the procedure to write the error somewhere and the procedure will continue to the end without aborting

1 Reply
best response confirmed by femola (Occasional Visitor)
Solution

Depending on the error servity you can handle errors using TRY...CATCH (Transact-SQL)