Created
January 29, 2016 14:20
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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