sp_addsubscriber_schedule (Transact-SQL)

适用于:SQL ServerAzure SQL 托管实例

为分发代理和合并代理添加计划。 此存储过程在发布服务器的任何数据库中执行。

Transact-SQL 语法约定

语法

sp_addsubscriber_schedule
    [ @subscriber = ] N'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 = ] N'publisher' ]
[ ; ]

参数

[ @subscriber = ] N'subscriber'

订阅服务器的名称。 @subscribersysname,无默认值。 @subscriber在数据库中必须唯一,并且不能存在NULL

[ @agent_type = ] agent_type

代理的类型。 @agent_type较小,可以是这些值之一。

说明
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 Last

[ @frequency_recurrence_factor = ] frequency_recurrence_factor

frequency_type使用的重复因子。 @frequency_recurrence_factor为 int,默认值为 0.

[ @frequency_subday = ] frequency_subday

在定义的时间段内重新安排的频率。 @frequency_subdayint,可以是以下值之一。

说明
1 一次
2 Second
4(默认值) Minute
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为 11:59:59:59(以 24 小时制为单位)。

[ @active_start_date = ] active_start_date

第一次计划分发代理的日期,格式为 yyyyMMdd@active_start_date为 int,默认值为 0.

[ @active_end_date = ] active_end_date

分发代理停止计划的日期,格式为 yyyyMMdd@active_end_dateint,默认值 99991231为 9999 年 12 月 31 日。

[ @publisher = ] N'publisher'

指定非 SQL Server 发布服务器。 @publisher为 sysname,默认值为 NULL.

不应为 SQL Server 发布服务器指定@publisher

返回代码值

0(成功)或 1(失败)。

注解

sp_addsubscriber_schedule用于快照 副本 (replica)、事务副本 (replica)和合并副本 (replica)。

权限

只有 sysadmin 固定服务器角色的成员才能执行sp_addsubscriber_schedule