sp_runtask (version 6.5)

Immediately executes a SQL Executive scheduled task either from a command batch or from a user-defined stored procedure.

Syntax

sp_runtask {'task_name' | @task_id = n }

where

task_name
Is the SQL Executive task name.
@task_id = n
Is the numeric ID of the task.

Remarks

This procedure must be run from the msdb database.

Example

A.    Run a Task from a Batch
    
PRINT 'Running sp_runtask...'
EXECUTE msdb.dbo.sp_runtask @taskid = 56
PRINT 'Finished'
  
B.    Run a Task from a Stored Procedure
    
CREATE PROC RunTask56 AS
BEGIN
    EXECUTE msdb.dbo.sp_runtask @taskid = 56
END
  

Permission

Execute permission defaults to the public group.