sp_addsubscriber_schedule (Transact-SQL)
为分发代理和合并代理添加计划。 此存储过程在发布服务器上对任何数据库执行。
语法
sp_addsubscriber_schedule [ @subscriber = ] 'subscriber'
[ , [ @agent_type = ] agent_type ]
[ , [ @frequency_type = ] frequency_type ]
[ , [ @frequency_interval = ] frequency_interval ]
[ , [ @frequency_relative_interval = ] frequency_relative_interval ]
[ , [ @frequency_recurrence_factor = ] frequency_recurrence_factor ]
[ , [ @frequency_subday = ] frequency_subday ]
[ , [ @frequency_subday_interval = ] frequency_subday_interval ]
[ , [ @active_start_time_of_day = ] active_start_time_of_day ]
[ , [ @active_end_time_of_day = ] active_end_time_of_day ]
[ , [ @active_start_date = ] active_start_date ]
[ , [ @active_end_date = ] active_end_date ]
[ , [ @publisher = ] 'publisher' ]
参数
[ @subscriber = ] 'subscriber'
订阅服务器的名称。 subscriber 的数据类型为 sysname。 订阅服务器的名称必须在数据库中唯一,不能已经存在,不能为 NULL。[ @agent_type = ] agent_type
代理的类型。 agent_type 的数据类型为 smallint,可以为下列值之一。值
说明
0(默认值)
分发代理
1
合并代理
[ @frequency_type = ] frequency_type
安排分发代理计划的频率。 frequency_type 的数据类型为 int,可以为下列值之一。值
说明
1
一次
2
按需
4
每天
8
每周
16
每月
32
与“每月”选项相关
64(默认值)
自动启动
128
重复执行
[ @frequency_interval = ] frequency_interval
应用到 frequency_type 所设置频率的值。 frequency_interval 的数据类型为 int,默认值为 1。[ @frequency_relative_interval = ] frequency_relative_interval
分发代理的日期。 在将 frequency_type 设置为 32(“每月”选项相关)时使用此参数。 frequency_relative_interval 的数据类型为 int,可以为下列值之一。值
说明
1(默认值)
第一次
2
第二次
4
第三次
8
第四次
16
最后一次
[ @frequency_recurrence_factor = ] frequency_recurrence_factor
是 frequency_type 使用的重复因子。 frequency_recurrence_factor 的数据类型为 int,默认值为 0。[ @frequency_subday = ] frequency_subday
在指定期内重新安排计划的频率。 frequency_subday 的数据类型为 int,可以为下列值之一。值
说明
1
一次
2
秒
4(默认值)
分钟
8
小时
[ @frequency_subday_interval = ] frequency_subday_interval
是 frequency_subday 的时间间隔。 frequency_subday_interval 的数据类型为 int,默认值为 5。[ @active_start_time_of_day = ] active_start_time_of_day
第一次安排分发代理的时间,格式为 HHMMSS。 active_start_time_of_day 的数据类型为 int,默认值为 0。[ @active_end_time_of_day = ] active_end_time_of_day
停止安排分发代理的时间,格式为 HHMMSS。 active_end_time_of_day 的数据类型为 int,默认值为 235959,表示 24 小时制的 11:59:59 P.M. 。[ @active_start_date = ] active_start_date
第一次安排分发代理的日期,格式为 YYYYMMDD。 active_start_date 的数据类型为 int,默认值为 0。[ @active_end_date = ] active_end_date
停止安排分发代理的日期,格式为 YYYYMMDD。 active_end_date 的数据类型为 int,默认值为 99991231,表示 9999 年 12 月 31 日。[ @publisher = ] 'publisher'
指定非 Microsoft SQL Server 发布服务器。 publisher 的数据类型为 sysname,默认值为 NULL。注意
不应为 SQL Server 发布服务器指定 publisher。
返回代码值
0(成功)或 1(失败)
注释
sp_addsubscriber_schedule 用于快照复制、事务复制和合并复制。
权限
只有 sysadmin 固定服务器角色的成员才能执行 sp_addsubscriber_schedule。