sp_stop_job

  • I'm using "EXEC msdb.dbo.sp_stop_job 'job name'" within a job-step to check whether it should stop the job or continue on based off some settings it checks.

    This marks the job as "Cancelled" which is understandable. Is there a similar command I can use that would stop the job but mark the job as "Success" instead?

    Best Regards,
    Ashkan

  • If you are managing the job status manually with those statements then you can use SP_UPDATE_JOB in thsi case, see BOL syntax:

    [font="Courier New"]USE msdb ;

    GO

    EXEC dbo.sp_update_job

    @job_name = N'NightlyBackups',

    @new_name = N'NightlyBackups -- Disabled',

    @description = N'Nightly backups disabled during server migration.',

    @enabled = 0 ;

    GO[/font]

    -Satya SK Jayanty
    SQL Server MVP (Follow me @sqlmaster)
    Author of SQL Server 2008 R2 Administration CookBook
    SQL Server Knowledge Sharing network

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

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