How to View Job Enable/Disable History

  • Dear all,

    I need to know when my job was enabled/disabled last time.

    What are the ways by which we can enabled & disable it programatically?

    Thanks in advance.

    Regards,

    Amit

  • amitdotchauhan (12/3/2010)


    I need to know when my job was enabled/disabled last time.

    You can get the last modified date from msdb.dbo.sysjobs, but it is referred to the whole job, not just to the enabled flag.

    What are the ways by which we can enabled & disable it programatically?

    You can use sp_update_job @job_id | @job_name, @enabled.

    For instance:

    -- Enable job 'UPDATE STATS'

    EXEC msdb.dbo.sp_update_job @job_name = 'UPDATE STATS', @enabled = 1

    -- Disable job 'UPDATE STATS'

    EXEC msdb.dbo.sp_update_job @job_name = 'UPDATE STATS', @enabled = 0

    Hope this helps,

    Gianluca

    -- Gianluca Sartori

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

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