• 相关软件
    >sp_update_jobschedule 创建者:webmaster 更新时间:2006-02-16 15:51

    更改指定作业的调度设置。



    语法


    sp_update_jobschedule [@job_id =] job_id, | [@job_name =] 'job_name',

        [@name =] 'name'

        
    [, [@new_name =] 'new_name']

        
    [, [@enabled =] enabled]

        [, [@freq_type =] freq_type]

        [, [@freq_interval =] freq_interval]

        [, [@freq_subday_type =] freq_subday_type]

        [, [@freq_subday_interval =] freq_subday_interval]

        [, [@freq_relative_interval =] freq_relative_interval]

        [, [@freq_recurrence_factor =] freq_recurrence_factor]

        [, [@active_start_date =] active_start_date]

        [, [@active_end_date =] active_end_date]

        [, [@active_start_time =] active_start_time]

        [, [@active_end_time =] active_end_time]



    参数


    [@job_id =] job_id



    是调度所属于的作业的标识号。job_id 的数据类型为 uniqueidentifier,其默认值为 NULL。



    [@job_name =] 'job_name'



    是调度所属于的作业的名称。各作业名称都必须是唯一的。job_name 的数据类型为 sysname,其默认值为 NULL。



    说明  必须或者指定 job_id 或者指定 job_name,但不能两个都指定。



    [@name =] 'name'



    是要修改的调度的名称。name 的数据类型为 sysname,无默认值。



    [@new_name =] 'new_name'



    是调度的新名称。new_name 的数据类型为 sysname,其默认值为 NULL。



    [@enabled =] enabled



    指定启用 (1) 或不启用 (0) 调度。enabled 的数据类型为 tinyint,其默认值为 NULL。



    [@freq_type =] freq_type



    指定该作业运行的频繁程度。freq_type 的数据类型为 int,其默认值为 NULL,且可以取下列值之一。












































    描述
    1一次。
    4按天。
    8按星期。
    16按月。
    32按月,相对于 freq_interval
    64当 SQL Server代理启动时运行。
    128当计算机空闲时运行。



    [@freq_interval =] freq_interval



    指定作业在哪一天运行。freq_interval 的数据类型为 int,其默认值为 NULL。freq_interval 的值取决于 freq_type 的值。







































     freq_type 的值freq_interval 的影响
    1(一次)未使用 freq_interval
    4(每天)每个 freq_interval 日。
    8(每周)freq_interval 是下列某个值或多个值(或 (OR) 在一起):

    1 = 星期日

    2 = 星期一

    4 = 星期二

    8 = 星期三

    16 = 星期四

    32 = 星期五

    64 = 星期六


    16(每月)每月的 freq_interval 日。
    32(每月相对信息)freq_interval 可以取下列值之一:

    1 = 星期日

    2 = 星期一

    3 = 星期二

    4 = 星期三

    5 = 星期四

    6 = 星期五

    7 = 星期六

    8 = 日

    9 = 工作日

    10 = 周末


    64(SQL Server 代理程序启动时)未使用 freq_interval



    [@freq_subday_type =] freq_subday_type



    指定 freq_subday_interval 的单位。freq_subday_type 的数据类型为 int,其默认值为 NULL,且可以取下列值之一。
























    描述(单位)
    0x1在指定的时间。
    0x4分钟。
    0x8小时。



    [@freq_subday_interval =] freq_subday_interval



    指定作业每次执行之间的周期数,周期以 freq_subday_type 为单位。freq_subday_interval 的数据类型为 int,其默认值为 NULL。



    [@freq_relative_interval =] freq_relative_interval



    freq_interval 的值为 32(每月相对信息)时,指定每月调度作业发生的 freq_intervalfreq_relative_interval 的数据类型为 int,其默认值为 NULL,且可以取下列值之一。


































    描述(单位)
    1第一个
    2第二个
    4第三个
    8第四个
    16最后一个



    [@freq_recurrence_factor =] freq_recurrence_factor



    指定作业各次调度执行之间的月数。freq_recurrence_factor 仅当 freq_type81632 时才使用。freq_recurrence_factor 的数据类型为 int,其默认值为 NULL。



    [@active_start_date =] active_start_date



    是作业可以开始执行的日期。active_start_date 的数据类型为 int,其默认值为 NULL。其值必须为 YYYYMMDD 格式。如果 active_start_date 不为 NULL,则日期必须大于或等于 19900101。



    [@active_end_date =] active_end_date



    是作业可以停止执行的日期。active_end_date 的数据类型为 int,其默认值为 NULL。其值必须为 YYYYMMDD 格式。



    [@active_start_time =] active_start_time



    是在 active_start_dateactive_end_date 之间任何一天作业开始执行的时间。active_start_time 的数据类型为 int,其默认值为 NULL。其值必须以 HHMMSS 的格式输入。



    [@active_end_time =] active_end_time



    是在 active_start_dateactive_end_date 之间任何一天作业停止执行的时间。active_end_time 的数据类型为 int,其默认值为 NULL。其值必须以 HHMMSS 的格式输入。



    返回代码值


    0(成功)或 1(失败)



    注释


    sp_update_jobschedule 必须从 msdb 数据库中运行。



    更新作业调度将增加作业的版本号。



    权限


    执行权限默认授予 public 角色。



    示例


    下例禁用 Archive Tables 作业的 Monday Archive 调度,并更改该调度的名称。



    USE msdb
    EXEC sp_update_jobschedule @job_name = 'Archive Tables',
      @name = 'Monday Archive',
      @new_name = 'Monday Archive - DEACTIVATED',
      @enabled = 0
    相关文章
    本页查看次数: