sp_addtask (version 6.5)

Creates a scheduled task. The @cmdexecsuccesscode parameter has been added.

For additional syntax information for sp_addtask, see SQL Server Books Online or the Microsoft SQL Server Transact-SQL Reference.

Syntax

sp_addtask name[, subsystem] [, server] [, username] [, databasename]
[, enabled] [, freqtype] [, freqinerval] [, freqsubtype] [, freqsubinterval]
[, freqrelativeinterval] [, freqrecurrencefactor] [, activestartdate]
[, activeenddate] [, activestarttimeofday] [, activeendtimeofday]
[, nextrundate] [, nextruntime] [, runpriority] [, emailoperatorname]
[, retryattempts] [, retrydelay] [, command] [, loghistcompletionlevel]
[, emailcompletionlevel] [, description] [, tagadditionalinfo] [, tagobjectid]
[, tagobjecttype] [, @newid OUTPUT] [, @cmdexecsuccesscode]

where

@cmdexecsuccesscode
Specifies an int value meaningful only for tasks whose @subsystem is CmdExec. This parameter is used by SQL Executive to determine if the CmdExec task failed or succeeded. If @cmdexecsuccesscode does not match the actual process exit code of the program involved in the task, the task is considered to have failed.