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