Which action should you take to implement error handling in your stored procedures?

You are the database designer for a manufacturing company on an instance of SQL Server 2008. You are creating several stored procedures that will update tables in your database.
You want each stored procedure to return a custom error message to the user if any of the DML statements in the stored procedure fail. Each custom error message must include the name of the procedure in which the error occurred and the error’s severity level.
Which action should you take to implement error handling in your stored procedures?
A. Implement an output parameter in each stored procedure to return the error message number.
B. Include a TRY…CATCH construct in each stored procedure and use the RAISERROR statement within each CATCH block.
C. Check the value of @@ERROR after each stored procedure call.
D. Add a custom error message for each stored procedure to the sysmessages table using the sp_addmessage system stored procedure.

microsoft-exams

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.