Exercise

CATCHING the RAISERROR

You need to select a product from the products table using a given product_id.

If the select statement doesn't find any product, you want to raise an error using the RAISERROR statement. You also need to catch possible errors in the execution.

Instructions 1/4

undefined XP
  • 1
    • Use RAISERROR with a severity of 11, a state of 1, and the given @product_id. This code will execute without errors.
  • 2
    • Set the value of @product_id to 50.
    • Click Run Code (not Submit Answer) to see the error.
    • Set @product_id back to 5.
  • 3
    • Catch the error generated by the RAISERROR statement you coded.
    • Select the error message using the appropriate function.
  • 4
    • Set the value of @product_idto 50.
    • Click Run Code (not Submit Answer) to see the error.
    • Set @product_id back to 5.