sp_update_job

Changes the attributes of a job.

Syntax

sp_update_job [ @job_id =] job_id | [@job_name =] 'job_name'
   [, [@new_name =] 'new_name' ]
   [, [@enabled =] enabled ]
   [, [@description =] 'description' ]
   [, [@start_step_id =] step_id ]
   [, [@category_name =] 'category' ]  /* not supported */
   [, [@owner_login_name =] 'login' ]
   [, [@notify_level_eventlog =] eventlog_level ]  /* not supported */
   [, [@notify_level_email =] email_level ]        /* not supported */
   [, [@notify_level_netsend =] netsend_level ]    /* not supported */
   [, [@notify_level_page =] page_level ]          /* not supported */
   [, [@notify_email_operator_name =] 'operator_name' ]       /* not supported */
   [, [@notify_netsend_operator_name =] 'netsend_operator' ]  /* not supported */
   [, [@notify_page_operator_name =] 'page_operator' ]        /* not supported */
   [, [@delete_level =] delete_level ]
   [, [@automatic_post =] automatic_post ]

Arguments

[ @job_id =] job_id

The identification number of the job to be updated. job_id is uniqueidentifier.

[ @job_name =] ‘job_name’

The name of the job. job_name is nvarchar(128).

Note

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

[ @new_name =] ‘new_name’

The new name for the job. new_name is nvarchar(128).

[ @enabled =] enabled

Specifies whether the job is enabled (1) or not enabled (0). enabled is tinyint.

[ @description =] ‘description’

The description of the job. description is nvarchar(512).

[ @start_step_id =] step_id

The identification number of the first step to execute for the job. step_id is int.

[ @category_name =] ‘category’ – not supported

The category of the job. category is nvarchar(128).

[ @owner_login_name =] ‘login’

The name of the login that owns the job. login is nvarchar(128). Only members of the sysadmin fixed server role can change job ownership.

[ @notify_level_eventlog =] eventlog_level – not supported

Specifies when to place an entry in the Microsoft Windows application log for this job. eventlog_level is int, and can be one of these values.

Value Description
0 Never
1 On success
2 (default) On failure
3 Always

[ @notify_level_email =] email_level – not supported

Parameter is for SQL Server compatibility and its value is ignored.

Specifies when to send an e-mail upon the completion of this job. email_level is int. email_level uses the same values as eventlog_level.

[ @notify_level_netsend =] netsend_level – not supported

Parameter is for SQL Server compatibility and its value is ignored.

netsend_level is int. netsend_level uses the same values as eventlog_level.

[ @notify_level_page =] page_level – not supported

Parameter is for SQL Server compatibility and its value is ignored.

page_level is int. page_level uses the same values as eventlog_level.

[ @notify_email_operator_name =] ‘operator_name’ – not supported

Parameter is for SQL Server compatibility and its value is ignored. email_name is nvarchar(128).

[ @notify_netsend_operator_name =] ‘netsend_operator’ – not supported

Parameter is for SQL Server compatibility and its value is ignored. netsend_operator is nvarchar(128).

[ @notify_page_operator_name =] ‘page_operator’ – not supported

Parameter is for SQL Server compatibility and its value is ignored.

page_operator is nvarchar(128).

[ @delete_level =] delete_level

Specifies when to delete the job. delete_value is int. _delete_level_ uses the same values as eventlog_level.

[ @automatic_post =] automatic_post

Reserved.

Remarks

sp_update_job changes only those settings for which parameter values are supplied. If a parameter is omitted, the current setting is retained.

Permissions

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.

Examples

The following example changes the name, description, and enabled status of the job RebuildCache.

EXEC dbo.sp_update_job
    @job_name = N'RebuildCache',
    @new_name = N'RebuildCache -- Disabled',
    @description = N'Nightly rebuild of caches disabled during server migration.',
    @enabled = 0 ;