Enable\Disable alerts with script

  • I have a need to disable an alert and then enable it after a process. I can do it manually via Management Studio but need to be able to do it programmatically. Anyone have any ideas?

  • You need to use sp_update_alert and set the enabled value to 0

    USE [msdb]

    GO

    EXEC msdb.dbo.sp_update_alert @name=N'Respond to DEADLOCK_GRAPH',

    @message_id=0,

    @severity=0,

    @enabled=0,

    @delay_between_responses=0,

    @include_event_description_in=5,

    @database_name=N'',

    @notification_message=N'',

    @event_description_keyword=N'',

    @performance_condition=N'',

    @wmi_namespace=N'\\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER',

    @wmi_query=N'SELECT * FROM DEADLOCK_GRAPH',

    @job_id=N'23196807-e886-4d50-9407-295b32f68105'

    GO

    Abhay Chaudhary
    Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply