sp_delete_job#

Deletes a job.

Syntax#

sp_delete_job { [ @job_id = ] job_id | [ @job_name = ] 'job_name' } ,
   [ , [ @originating_server = ] 'server' ]
   [ , [ @delete_history = ] delete_history ]
   [ , [ @delete_unused_schedule = ] delete_unused_schedule ]

Arguments#

[ @job_id = ] job_id

Is the identification number of the job to be deleted. job_id is uniqueidentifier, with a default of NULL.

[ @job_name = ] ‘job_name’

Is the name of the job to be deleted. job_name is sysname, with a default of NULL.

Note

Either job_id or job_name must be specified; both cannot be specified.

[ @originating_server = ] ‘server’

For internal use.

[ @delete_history = ] delete_history

Specifies whether to delete the history for the job. _delete_history_ is bit, with a default of 1. When _delete_history_ is 1, the job history for the job is deleted. When _delete_history_ is 0, the job history is not deleted.

[ @delete_unused_schedule = ] delete_unused_schedule

Specifies whether to delete the schedules attached to this job if they are not attached to any other job. _delete_unused_schedule_ is bit, with a default of 1. When _delete_unused_schedule_ is 1, schedules attached to this job are deleted if no other jobs reference the schedule. When _delete_unused_schedule_ is 0, the schedules are not deleted.

Result Sets#

None

Remarks#

The @delete_unused_schedule argument provides Querona’s backward compatibility with legacy SQL Server by automatically removing schedules that are not attached to any job. To retain schedules that are not attached to a job, you must provide the value 0 as the @delete_unused_schedule argument.

Querona Administrative Portal provides an easy, graphical way to manage jobs, and is the recommended way to create and manage the jobs.

Permissions#

By default, members of the sysadmin fixed server role can execute this stored procedure. Other users must be granted the ALTER ANY JOB privilege.

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.

Examples#

The following example deletes the job “RebuildCache”.

EXEC sp_delete_job
    @job_name = N'RebuildCache';

See Also#