Delete Jobs

APPLIES TO: yesSQL Server yesAzure SQL Database (Managed Instance only) noAzure SQL Data Warehouse noParallel Data Warehouse

Important

On Azure SQL Database Managed Instance, most, but not all SQL Server Agent features are currently supported. See Azure SQL Database Managed Instance T-SQL differences from SQL Server for details.

A job is a specified series of operations performed sequentially by SQL Server Agent. By default, jobs are not deleted when execution finishes. You can delete one or more MicrosoftSQL Server Agent jobs regardless of success or failure of the job. You can also configure MicrosoftSQL Server Agent to automatically delete jobs when they succeed, fail, or complete.

By default, members of the sysadmin fixed server role can execute the sp_delete_job (Transact-SQL) system stored procedure to delete a job. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:

  • SQLAgentUserRole

  • SQLAgentReaderRole

  • SQLAgentOperatorRole

For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.

Members of the sysadmin fixed server role can execute sp_delete_job to delete any job. A user that is not a member of the sysadmin fixed server role can only delete jobs owned by that user.

Description Topic
Describes how to delete one or more MicrosoftSQL Server Agent jobs. Delete One or More Jobs
Describes how to configure MicrosoftSQL Server Agent to automatically delete jobs when they succeed, fail, or complete. Automatically Delete a Job