SQL Server alerting

pma111 used Ask the Experts™
1) what kind of issues do you have MSSQL alert your DBA's to specific to SQL Server? I know there are a bunch of standard alerts to servers in general, e.g. free space, CPU, memory etc, but I am intrigued to know what specific database issues you deem critical enough to be alerted upon as and when they arise?

2) I'm also interested in whether you can query MSSQL to determine all agent jobs configured, and whether a DBA has been configured to receive an email as and when the job fails/succeeds, and if so what email address has been configured?

3) also whether you can get a query on what alerts are configured within a  SQL Server instance itself currently. And who is configured to get the alerts. - msdb.dbo.sysalerts  looks possibily like what I am after.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Analyst
Here are some answers in order:
1. I would consider enabling standard alerts 823,824,825, and 16-25 as described here https://www.brentozar.com/blitz/configure-sql-server-alerts/ at least on any SQL production box. Aside that you could have custom alerts set for db files getting full, locking/blocking, long running SQL Jobs, PLE, High CPU, etc.

2.  You can run a SQL code like below to get all SQL Jobs info and there are lot more available free on the net if you search for particular details of each job:
use msdb

	sj.name as JobName, 
	case when sj.enabled=1 then 'Yes' when sj.enabled=0 then 'No' end as JobEnabled, 
	sj.date_created as JobCreated, 
	sj.date_modified as JobModified,
	js.next_run_date as NextRunDate,
	js.next_run_time as NextRunTime,
	sc.name as ScheduleName,
	case when sc.enabled=1 then 'Yes' when sc.enabled=0 then 'No' end as Scheduled,
	case when sc.freq_type = 4 then 'Daily'
		when sc.freq_type = 8 then 'Weekly'
		when sc.freq_type = 16 then 'Monthly'
	end as Frequency
from dbo.sysjobs sj 
	inner join dbo.sysjobschedules js on sj.job_id=js.job_id
	inner join dbo.sysschedules sc on js.schedule_id=sc.schedule_id
-- where sj.enabled=1 -- uncomment this line to get only enabled jobs list
order by js.next_run_time;

Open in new window

3. to find all enabled alerts you could run the code below which was originally posted here: http://www.sqlservercentral.com/scripts/msdb/110605/

--Run on source server

SELECT 'IF (EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = N'''+NAME+'''))
 ---- Delete the alert with the same name.
  EXECUTE msdb.dbo.sp_delete_alert @name = N'''+name+''' 
EXECUTE msdb.dbo.sp_add_alert @name = N'''+name+''', @message_id = '+CAST(message_id AS VARCHAR(10))+' , @severity = '+CAST(severity AS VARCHAR(10))+' , @enabled = 1, @delay_between_responses = '+CAST(delay_between_responses AS VARCHAR(10))+' , @include_event_description_in = '+CAST(include_event_description AS VARCHAR(10))+', @category_name = N''[Uncategorized]''
' FROM [msdb].[dbo].[sysalerts]
WHERE category_id <> 20;

--Add email notifications amend DBA to your operator
SELECT 'EXEC msdb.dbo.sp_add_notification @alert_name=N'''+NAME+''', @operator_name=N''DBA'', @notification_method = 7;'
FROM [msdb].[dbo].[sysalerts]
WHERE category_id <> 20;

Open in new window

Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2018

1. It would depend upon the criticality of the databases involved.. As a DBA, we would need to monitor the Free space and other parameters mentioned by you and lcohan above in addition to Deadlocks, Blockings happening on the database. As an Application DBA, they might have several jobs to ensure data integrity, alerting in case of invalid records and so on..
2 & 3..
Below script would help to identify the list of jobs without operators configured..
Slightly modifying would help you in identifying the jobs with operators configured and the list of jobs as requested as well..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial