Wednesday, August 01, 2012

SQL Agent Alert

This is an example of sending email to dbteam if a process is blocked for longer than 10 minutes.

USE [msdb]
GO
EXEC msdb.dbo.sp_add_alert @name=N'xxxIsBlocked',
        @enabled=1,
        @delay_between_responses=0,
        @include_event_description_in=1,
        @notification_message=N'A process''s waiting for lock for more than 10 minutes',
        @performance_condition=N'SQLServer:Locks|Lock Wait Time (ms)|Key|>|600000',
        @job_id=N'00000000-0000-0000-0000-000000000000'
GO
EXEC msdb.dbo.sp_add_notification @alert_name=N'xxxIsBlocked', @operator_name=N'DBTeam', @notification_method = 1
GO

No comments: