Search code examples
sql-serversql-agent-job

What is the difference between Enable a job and Start a job in Sql Server Agent


Well, I'm new to this... I trying to understand the difference between Enabling a Sql Job and Starting a Job at a step? The both seem to work in the same manner... or is there a difference?


Solution

  • Enabling a Sql Agent Job - means Job is active on server and will be executed on scheduled time Starting a Job step - means either server has started a job step on scheduled time or you have started it forcefully,
    Lets say a job has 5 steps and you don't want to execute first 3, here SQL Server Agent provide you facility that you can start a job execution from step 4.

    http://msdn.microsoft.com/en-us/library/ms189817.aspx

    SELECT  [enabled] --enabled Indicates whether the job is enabled to be executed.
            ,name
    FROM    msdb.dbo.sysjobs
    WHERE   name = 'Your Job Name'
    

    http://msdn.microsoft.com/en-us/library/ms187387.aspx

    SELECT  step_id,
            step_name -- Name of the job step
    FROM    msdb.dbo.SysJobSteps
    WHERE   job_id = ( SELECT   job_id
                       FROM      msdb.dbo.sysjobs
                       WHERE    name =  'Your Job Name'
                     )