sp_start_job#

Instructs the scheduler to execute a job immediately.

Syntax#

sp_start_job
    {   [@job_name    = ] 'job_name'
      | [@job_id      = ] job_id }
    [ , [@error_flag  = ] error_flag]
    [ , [@server_name = ] 'server_name']
    [ , [@step_name   = ] 'step_name']
    [ , [@output_flag = ] output_flag]

Arguments#

[ @job_name = ] ‘job_name’

The name of the job to start. Either job_id or job_name must be specified, but both cannot be specified. job_name is sysname, with a default of NULL.

[ @job_id = ] job_id

The identification number of the job to start. Either job_id or job_name must be specified, but both cannot be specified. job_id is uniqueidentifier, with a default of NULL.

[ @error_flag = ] error_flag

Identified for informational purposes only. Not supported.

[ @server_name = ] ‘server_name’

The target server on which to start the job. _server_name_ is nvarchar(128), with a default of NULL. _server_name_ must be one of the target servers to which the job is currently targeted.

[ @step_name = ] ‘step_name’

The name of the step at which to begin execution of the job. Applies only to local jobs. _step_name_ is sysname, with a default of NULL

[ @output_flag = ] output_flag

Identified for informational purposes only. Not supported.

Result Sets#

None

Permissions#

By default, members of the sysadmin fixed server role can execute this stored procedure.

Members of sysadmin can start any job.

Examples#

The following example starts a job named Weekly Sales Cache Rebuild.

EXEC dbo.sp_start_job N'Weekly Sales Cache Rebuild';