SQL_EXECUTE_JOB

Use the SQL_EXECUTE_JOB script element to execute a job on the MS SQL Server. To start MS SQL jobs, the agent uses the sp_start_job stored procedure in the msdb database.

Important!

  • The AE job aborts if the user is not authorized, or if a database other than Microsoft SQL Server is used.

  • If you terminate the AE job while the MS SQL job is still active, the agent calls the sp_stop_job stored procedure. The MS SQL job therefore does not abort immediately, but is monitored until it has officially ended.

Tip: You can write a script to retrieve a list of all available MS SQL jobs. For more information, see SQL_GET_JOBS.

Syntax

SQL_EXECUTE_JOB JOB=...

Parameters

Parameter Description Format
JOB= Name of the MS SQL job Script literal

Return Codes

The status of the AE job reflects how the started MS SQL job was processed:

Return Value Condition
ENDED_OK The MS SQL job ended successfully
ENDED_NOT_OK The MS SQL job aborted
ENDED_CANCEL The user canceled the MS SQL job

Examples

The following example executes the MS SQL job named Integrity Checks Job for DB Maintenance Plan.

SQL_EXECUTE_JOB JOB="Integrity Checks Job for DB Maintenance Plan";

See also: