RAISERROR
raises an error
What changes
- Input
- message id or text, severity, state, arguments
- Output or change
- error or informational message; severity 11-19 inside TRY transfers to CATCH
Syntax at a glance
RAISERROR ( { msg_id | msg_str | @local_variable } { , severity , state } [ , argument [ , ...n ] ] ) [ WITH option [ , ...n ] ]
Work example
A legacy module reports a message or raises an error with behavior tied to severity and state.
Check the severity, state, and transaction behavior. Prefer THROW for new error paths unless a documented RAISERROR feature is required.
Check your work RAISERROR. The test confirms whether execution continues or enters CATCH at the selected severity.
Open Microsoft Learn for full syntax, permissions, and details for your version.