Skip to content

Instantly share code, notes, and snippets.

@mbourgon
Created January 29, 2016 14:20
Show Gist options
  • Save mbourgon/55f6804a7c5f5a5acd63 to your computer and use it in GitHub Desktop.
Save mbourgon/55f6804a7c5f5a5acd63 to your computer and use it in GitHub Desktop.
Event Notifications - make sure something's inserted into the table in the last hour. If not, EMAIL.
DECLARE @last_insert DATETIME
SET @last_insert = (SELECT TOP 1 insert_datetime FROM EventNotificationRec.dbo.ENAudit_Events ORDER BY id DESC)
SELECT @last_insert
SELECT DATEDIFF(MINUTE,@last_insert, GETDATE())
IF (SELECT DATEDIFF(MINUTE,@last_insert, GETDATE())) >60
begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'me',
@recipients = '[email protected]',
@subject = '[Priority1] Alert! EN is DOWN!',
@body = 'ALERT! The Event Notification table has not received any new messages in over an hour. Investigate immediately.'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment