1. Learn
  2. /
  3. Courses
  4. /
  5. Transactions and Error Handling in SQL Server

Connected

Exercise

FORMATMESSAGE with message number

Like in the previous exercise, you need to check if there is enough stock when you sell a product.

This time you want to add your custom error message to the sys.messages catalog, by executing the sp_addmessage stored procedure. Once you have added the message, you can use it in the FORMATMESSAGE function.

Instructions 1/3

undefined XP
    1
    2
    3
  • Add the new message by passing to the sp_addmessage stored procedure 50002 as the message id, 16 as the severity, and 'There are not enough %s bikes. You only have %d in stock.' as the message text.