Session Ready
Exercise

THROW with parameters

You need to prepare a script to select all the information of a member from the staff table using a given staff_id.

If the select statement doesn't find any member, you want to throw an error using the THROW statement. You need to warn there is no staff member with such id.

Instructions
100 XP
  • Use the THROW statement, with 50001 as the error number, 'No staff member with such id' as the message text, and 1 as the state.
  • Replace the value of @staff_id in the DECLARE statement at the beginning with an identifier that doesn't exist (e.g. '45') and click Run Code (not Run Solution). You will see the error.
  • Set the value of @staff_id back to 4 and run the code without errors.