sp_updatetask SQL Executive Stored Procedure

Updates information about a task.

Syntax

sp_updatetask {currentname | id} [, name] [, subsystem] [, server] [, username] [, databasename] [, enabled] [, freqtype] [, freqinterval] [, freqsubtype] [, freqsubinterval] [, freqrelativeinterval] [, freqrecurrencefactor] [, activestartdate] [, activeenddate] [, activestarttimeofday] [, activeendtimeofday] [, nextrundate] [, nextruntime] [, runpriority] [, emailoperatorname] [, retryattempts] [, retrydelay] [, command] [, loghistcompletionlevel] [, emailcompletionlevel] [, description] [, tagadditionalinfo] [, tagobjectid] [, tagobjecttype]

where

currentname | id
Specifies which task to update.
name
Specifies a new name for the task.
subsystem
For replication, specifies which subsystem to use. Can be Distribution, LogReader, or Sync. These must be typed using the capitalization (case) shown.
server
Specifies the name of server on which to execute this task.
username
Specifies the database user to impersonate when creating this task. Only the system administrator or the database owner can specify this parameter.
databasename
Specifies the database to use when executing the task.
enabled
Specifies the status of scheduled tasks: 1 indicates enabled (tasks will be scheduled and run), 0 indicates disabled.
freqtype
Specifies the frequency with which to schedule this task:
1One Time
2On Demand (the default)
4Daily
8Weekly
16Monthly
32Monthly Relative
64Autostart
124Recurring
freqinterval
Specifies the interval for freqtype.
freqsubtype
Specifies how often to reschedule during the defined period:
1 Once (the default)
2 Second
4 Minute
8 Hour
freqsubinterval
Specifies the value for freqsubtype when the subtype is set to second, minute, or hour.
freqrelativeinterval
Is the value used when freqtype is set to 32 (monthly relative). Indicates the first, second, third, fourth, or last day of the month.

1First (the default)
2Second
4Third
8Fourth
16Last

freqrecurrencefactor
Specifies how often the task should re-occur during the defined freqtype.
activestartdate
Specifies the date when this task will be scheduled initially. Formatted as YYYYMMDD. The default is 0.
activeenddate
Specifies the date when this task will stop being scheduled. Formatted as YYYYMMDD. The default is 0.
activestarttimeofday
Specifies the time this task will be scheduled initially. Formatted as HHMMSS. The default is 0.
activeendtimeofday
Specifies when this task will stop being scheduled. Formatted as HHMMSS. The default is 0.
nextrundate
Specifies the date the task will be scheduled. If the current date is greater than activestartdate, specifies the next date that the task will be scheduled: 0 indicates that the SQL Executive will calculate the next appropriate date. Formatted as YYYYMMDD. The default is 0.
nextruntime
Specifies the time the task will be scheduled. If the current time is greater than the activestarttime, specifies the next time that the task will be scheduled: 0 indicates that the SQL Executive will calculate the next appropriate time. Formatted as HHMMSS. The default is 0.
runpriority
Specifies the thread priority level at which the subsystem event thread runs. The default is 0.
emailoperatorname
Specifies the e-mail name of the operator who will receive notifications.
retryattempts
Specifies the number of times the SQL Executive retries before issuing an error. The default is 0.
retrydelay
Specifies the SQL Executive the SQL Executive waits before retrying the task. The default is 1.
command
Specifies a command string (based on the valid specified subsystem commands) to be passed to the subsystem. If the specified subsystem is TSQL, the command cannot consist of more than one batch. The batch separator GO is not supported. The default is NULL.
loghistcompletionlevel
Specifies the level of events to capture in the event log, 1 captures all successfully run events, 2 captures only failed events.
emailcompletionlevel
Specifies the level of events to capture via e-mail, 1 captures all successfully run events, 2 captures only failed events. The default is 2.
description
Is text describing the task.
tagadditionalinfo
Reserved for future use.
tagobjectid
Reserved for future use.
tagobjecttype
Reserved for future use.

Remarks

All specified (non-NULL) parameters are updated. To clear a string, use ' '.

Examples

This example renames the auth_table_sync task to authors_sync.

sp_updatetask 'auth_table_sync', @name = 'authors_sync'

Permission

Only the system administrator can use this procedure.

Table Used

systasks

See Also

sp_droptask sp_addtask