liveBook · Manning

Severity

As explained in 100 SQL Server Mistakes and How to Avoid Them

An error severity level is a SQL Server classification indicating the informational, user-correctable, administrative, or fatal nature of an error.

Severity classifies a SQL Server message by operational impact. Levels 0–10 are informational rather than errors; level 10 is reported as level 0 for compatibility. Levels 11–16 describe errors a user can usually correct, including syntax, object-name, permission, and deadlock problems. Levels 17–19 generally require an administrator, while levels 20–24 are fatal, such as database or media corruption. section 7.1

Use severity to choose an error-handling response:

  • Treat levels 0–10 as messages: execution continues because they are informational. section 7.1
  • Handle levels 11–19 with TRY..CATCH. These severities transfer execution to the CATCH block, where transaction rollback and a meaningful error can be issued. section 7.1
  • Do not rely on CATCH for severity 20 or higher. Fatal errors can make continued handling pointless because the connection may be closed. section 7.1
  • Plan operational attention for levels 19–24, which are written to the error log; unattended processes may also need alerts for raised errors. section 7.1 section 7.7

A duplicate sales order is a level-16 problem

A duplicate primary-key insertion reports level 14, placing it among user-correctable errors. A procedure can catch that failure, roll back the transaction, and raise a clearer custom message such as “A duplicate sales order has been entered.” THROW can rethrow an original error or raise a custom number, message, and state, but its severity is always 16 and it cannot use a message stored in sys.messages. RAISERROR() supports custom messages and severity selection. section 7.1 section 7.1 section 7.1

A practical rule is to distinguish a recoverable application or input failure from an administrative condition and from a fatal failure. Pair severity-aware TRY..CATCH handling with transaction rollback, useful messages, logging, and alerting rather than assuming every error can be safely processed in the same way. section 7.1 section 7.7

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Classifies all 25 levels and explains TRY..CATCH behavior, error logging, and THROW’s fixed level without detailing engine internals.
Examples
Uses invalid object names, foreign-key failures, duplicate keys, custom messages, and a sales-order procedure to illustrate severity.
What it assumes
Introduces severity classifications from zero while using T-SQL transactions and TRY..CATCH as the surrounding context.
What you can do after
Evaluate/understand which SQL Server errors can enter CATCH, need administrative action, or may be fatal.
How it connects
Connects severity with TRY..CATCH, transactions, XACT_ABORT, THROW, RAISERROR(), error logging, and alerting.

Also explained in

Compare how 7 books explain severity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.