sp_start_job (T-SQL)

Instructs SQL Server Agent 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'
Is 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
Is 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
Reserved.
[@server_name =] 'server_name'
Is the target server on which to start the job. server_name is nvarchar(30), 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'
Is 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
Reserved.
Return Code Values

0 (success) or 1 (failure)

Result Sets

None

Permissions

Execute permissions default to the public role.

Examples

This example starts a job named Nightly Backup.

USE msdb

EXEC sp_start_job @job_name = 'Nightly Backup'

  

See Also
sp_delete_job sp_update_job
sp_help_job System Stored Procedures
sp_stop_job  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.