SQL Server alerting

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.
LVL 4
pma111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
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
go

select 
	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
USE MSDB
GO

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+''' 
BEGIN 
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]''
END
' 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
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..
https://basitaalishan.com/2012/08/12/how-to-find-sql-agent-jobs-without-notification-operator-configured/
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.