Instructs SQL Server Agent to stop the execution of a job.
sp_stop_job [@job_name =] 'job_name'
| [@job_id =] job_id
| [@originating_server =] 'master_server'
| [@server_name =] 'target_server'
Note Only one of the first three parameters can be specified.
0 (success) or 1 (failure)
None
If a job is currently executing a step of type CmdExec, the process being run (for example, MyProgram.exe) is forced to end prematurely. Premature ending can result in unpredictable behavior such as files in use by the process being held open. Consequently, sp_stop_job should be used only in extreme circumstances if the job contains steps of type CmdExec.
Execute permissions default to the public role.
This example stops a job named Archive Tables.
USE msdb
EXEC sp_stop_job @job_name = 'Archive Tables'
sp_delete_job | sp_update_job |
sp_help_job | System Stored Procedures |
sp_start_job |