Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Checking if key job is enabled

Author  Topic 

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-04-21 : 13:37:34
Ever have one of those days where you are working on a database and disable jobs until you are finished. A month later you realize that you weren't doing something that you should have been? I wrote the following script after realizing that another system administrator had disabled a key job "temporarily" and then forgot to turn it back on. The script simply checks the sysjobs table for a key job name that you give it and will email you if that job gets disabled for any reason.

[CODE]declare @enabled as integer
select @enabled = enabled from msdb..sysjobs where name = '[Daily] ServerName Nightly Backup/Maintenance'
if @enabled = 0
begin
exec master..xp_sendmail @recipients = 'email.goes@here', @subject = '** Nigthly backup job is not enabled **', @message = 'This is to inform that for whatever reason the nigthly backup job for SERVER NAME that should be enabled has been disabled and will not be executed tonight'
end[/CODE]
   

- Advertisement -