Skip to content

Mr SQL's Blog

Musings on Microsoft SQL Server

Tag Archives: sp_add_notification

SQL Server errors with a severity level of 19 or above are considered fatal errors. The following is taken from Books online:-

Severity Level 19: SQL Server Error in Resource

These messages indicate that some nonconfigurable internal limit has been exceeded and the current batch process is terminated. Severity level 19 errors occur rarely; however, they must be corrected by the system administrator or your primary support provider. The administrator should be informed every time a severity level 19 message occurs.

Severity Levels 20 through 25

Severity levels from 20 through 25 indicate system problems. These are fatal errors, which means that the process (the program code that accomplishes the task specified in your statement) is no longer running. The process freezes before it stops, records information about what occurred, and then terminates. The client connection to SQL Server closes, and depending on the problem, the client might not be able to reconnect.

Error messages with a severity level of 19 or higher stop the current batch. Errors messages with a severity level of 20 or higher are considered fatal errors and terminate the client connection. Errors messages in this range may affect all of the processes in the database, and may indicate that a database or object is damaged. Error messages with a severity level from 19 through 25 are written to the error log.

Severity Level 20: SQL Server Fatal Error in Current Process

These messages indicate that a statement has encountered a problem. Because the problem has affected only the current process, it is unlikely that the database itself has been damaged.

Severity Level 21: SQL Server Fatal Error in Database (dbid) Processes

These messages indicate that you have encountered a problem that affects all processes in the current database; however, it is unlikely that the database itself has been damaged.

Severity Level 22: SQL Server Fatal Error Table Integrity Suspect

These messages indicate that the table or index specified in the message has been damaged by a software or hardware problem.

Severity level 22 errors occur rarely; however, if you should encounter one, run DBCC CHECKDB to determine if other objects in the database are also damaged. It is possible that the problem is in the cache only and not on the disk itself. If so, restarting SQL Server corrects the problem. To continue working, you must reconnect to SQL Server. Otherwise, use DBCC to repair the problem. In some cases, it may be necessary to restore the database.

If restarting does not help, the problem is on the disk. Sometimes destroying the object specified in the error message can solve the problem. For example, if the message tells you that SQL Server has found a row with a length of 0 in a nonclustered index, delete the index and rebuild it.

Severity Level 23: SQL Server Fatal Error: Database Integrity Suspect

These messages indicate that the integrity of the entire database is in question because of a hardware or software problem.

Severity level 23 errors occur rarely; however, if you should encounter one, run DBCC CHECKDB to determine the extent of the damage. It is possible that the problem is in the cache only and not on the disk itself. If so, restarting SQL Server corrects the problem. To continue working, you must reconnect to SQL Server. Otherwise, use DBCC to repair the problem. In some cases, it may be necessary to restore the database.

Severity Level 24: Hardware Error

These messages indicate some type of media failure. The system administrator might have to reload the database. It might also be necessary to call your hardware vendor.

Setting up Alerts

You should set up alerts in SQL Server Agent for any errors that have a severity level of 19 or above. Use the following script to generate the alerts, ensuring you replace “Operator Name” with the appropriate name of the operator to notify by email:-

USE [msdb]
GO

EXEC msdb.dbo.sp_add_alert @name=N'019 - Fatal Error In Resource',
		@message_id=0,
		@severity=19,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'020 - Fatal Error in Current Process',
		@message_id=0,
		@severity=20,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'021 - Fatal Error in Database Processes',
		@message_id=0,
		@severity=21,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'022 - Fatal Error: Table Integrity Suspect',
		@message_id=0,
		@severity=22,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'023 - Fatal Error: Database Integrity Suspect',
		@message_id=0,
		@severity=23,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'024 - Fatal Error: Hardware Error',
		@message_id=0,
		@severity=24,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_alert @name=N'025 - Fatal Error',
		@message_id=0,
		@severity=25,
		@enabled=1,
		@delay_between_responses=1800,
		@include_event_description_in=1,
		@category_name=N'[Uncategorized]',
		@job_id=N'00000000-0000-0000-0000-000000000000'
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'019 - Fatal Error In Resource', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'020 - Fatal Error in Current Process', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'021 - Fatal Error in Database Processes', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'022 - Fatal Error: Table Integrity Suspect', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'023 - Fatal Error: Database Integrity Suspect', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'024 - Fatal Error: Hardware Error', @operator_name=N'Operator Name', @notification_method = 1
GO

EXEC msdb.dbo.sp_add_notification @alert_name=N'025 - Fatal Error', @operator_name=N'Operator Name', @notification_method = 1
GO

Tags: , , ,

%d bloggers like this: