title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | dev_langs | monikerRange | |
---|---|---|---|---|---|---|---|---|---|---|
jobs.sp_stop_job (Azure Elastic Jobs) (Transact-SQL) |
jobs.sp_stop_job instructs the elastic job agent to stop a job execution in the Azure Elastic Jobs service for Azure SQL Database. |
WilliamDAssafMSFT |
wiassaf |
10/30/2023 |
sql-database |
system-objects |
reference |
|
=azuresqldb-current |
[!INCLUDE Azure SQL Database]
Instructs the elastic job agent to stop a job execution in the Azure Elastic Jobs service for Azure SQL Database.
This stored procedure shares the name of sp_stop_job
with a similar object in [!INCLUDE ssnoversion-md] for the [!INCLUDE ssnoversion-md] Agent service. For information about the [!INCLUDE ssnoversion-md] Agent version, see sp_stop_job (Transact-SQL).
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
[jobs].sp_stop_job [ @job_execution_id = ] ' job_execution_id '
The identification number of the job execution to stop. job_execution_id is uniqueidentifier, with default of NULL
.
0 (success) or 1 (failure)
By default, members of the sysadmin fixed server role can execute this stored procedure. Only members of sysadmin can use this stored procedure to edit the attributes of jobs that are owned by other users.
All times in elastic jobs are in the UTC time zone.
To identify the job_execution_id
of a current job execution, use jobs.job_executions.
The following example shows how to identify a job execution in jobs.job_executions and then cancel a job execution using the job_execution_id
, for example 01234567-89ab-cdef-0123-456789abcdef
.
Connect to the job_database
and run the following command:
--Connect to the job database specified when creating the job agent
-- View all active executions to determine job_execution_id
SELECT job_name
, job_execution_id
, job_version
, step_id
, is_active
, lifecycle
, start_time
, current_attempts
, current_attempt_start_time
, last_message
, target_group_name
, target_server_name
, target_database_name
FROM jobs.job_executions
WHERE is_active = 1 AND job_name = 'ResultPoolsJob'
ORDER BY start_time DESC;
GO
-- Cancel job execution with the specified job_execution_id
EXEC jobs.sp_stop_job '01234567-89ab-cdef-0123-456789abcdef';