sys.sp_stop_job
generalDescription
Instructs SQL Server Agent to stop the execution of a job. The identification number of the job to stop.
Syntax
sp_stop_job
[ [ @job_name = ]
N
'job_name'
]
[ , [ @job_id = ]
'job_id'
]
[ , [ @originating_server = ]
N
'originating_server'
]
[ , [ @server_name = ]
N
'server_name'
]
[ ; ]
Permissions
The name of the specific target server on which to stop a multiserver job. @server_name is , with a default of. Specify this parameter only when calling at an originating server for a multiserver job. (success) or (failure). None. sends a stop signal to the database. Some processes can be stopped immediately and some must reach a stable point (or an entry point to the code path) before they can stop. Some long-running Transact-SQL statements such as , , and some commands can take a long time to finish. When these commands are running, it might take a while before the job is canceled. Stopping a job causes a “Job Canceled” entry to be recorded in the job history. If a job is currently executing a step of type or , 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. Thus, should be used only in extreme circumstances if the job contains steps of type or. This stored procedure shares the name of with a similar object for the Azure Elastic Jobs service for Azure SQL Database. For information about the elastic jobs version, see jobs.sp_stop_job (Azure Elastic Jobs). 7 Note Only one of the first three parameters can be specified.