Transact-SQL 参考

sp_addmergesubscription

创建强制或请求合并订阅。此存储过程在发布服务器的发布数据库上执行。

语法

sp_addmergesubscription [ @publication = ] 'publication'
    [ , [ @subscriber = ] 'subscriber' ]
    [ , [ @subscriber_db = ] 'subscriber_db' ]
    [ , [ @subscription_type = ] 'subscription_type' ]
    [ , [ @subscriber_type = ] 'subscriber_type' ]
    [ , [ @subscription_priority = ] subscription_priority ]
    
[ , [ @sync_type = ] 'sync_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 ]
    [ , [ @optional_command_line = ] 'optional_command_line' ]
    [ , [ @description = ] 'description' ]
    [ , [ @enabled_for_syncmgr = ] 'enabled_for_syncmgr' ]
    [ , [ @offloadagent = ] remote_agent_activation ]
    [ , [ @offloadserver = ] 'remote_agent_server_name' ]
    [ , [ @use_interactive_resolver = ] 'use_interactive_resolver' ]
    [ , [ @merge_job_name = ] 'merge_job_name' ]

参数

[@publication = ] 'publication'

是发布名。publication 的数据类型为 sysname,没有默认设置。发布必须已存在。

[@subscriber = ] 'subscriber'

是订阅服务器名。subscriber 的数据类型为 sysname,默认设置为 NULL。

[@subscriber_db = ] 'subscriber_db'

是订阅数据库名称。subscriber_db 的数据类型为 sysname,默认设置为 NULL。

[@subscription_type = ] 'subscription_type'

是订阅的类型。subscription_type 的数据类型为 nvarchar(15),默认设置为 PUSH。如果是 push,则添加强制订阅并在分发服务器上添加合并代理程序。如果是 pull,则在分发服务器上不添加合并代理程序的情况下添加请求订阅。

说明  匿名订阅无需使用此存储过程。

[@subscriber_type = ] 'subscriber_type'

是订阅服务器的类型。subscriber_type 的数据类型为 nvarchar(15),可以是下列值之一。

描述
local(默认值) 订阅服务器仅对发布服务器是已知的。
global 订阅服务器对所有服务器都是已知的。

[@subscription_priority = ] subscription_priority

是表示订阅优先级的数字。subscription_priority 的数据类型为 real,默认设置为 NULL。对于本地订阅和匿名订阅,优先级为 0.0。对于全局订阅,优先级必须小于 100.0。有关更多信息,请参见订阅类型和冲突

[@sync_type = ] 'sync_type'

是订阅同步类型。sync_type 的数据类型为 nvarchar(15),默认设置为 automatic。可以是 automaticnone。如果是 automatic,则表示首先将已发布表的架构和初始数据传输到订阅服务器。如果是 none,则假定订阅服务器已有已发布表的架构和初始数据。始终传输系统表和数据。

[@frequency_type = ] frequency_type

是表示合并代理程序何时运行的值。frequency_type 的数据类型为 int,可以是下列值之一。

描述
1 一次
4 每天
8 每周
10 每月
20 每月,相对于频率间隔
40 当 SQL Server 代理程序启动时
NULL(默认值)  

[@frequency_interval = ] frequency_interval

是合并代理程序运行的日期。frequency_interval 的数据类型为 int,可以是下列值之一。

描述
1 星期日
2 星期一
3 星期二
4 星期三
5 星期四
6 星期五
7 星期六
8
9 工作日
10 周末
NULL(默认值)  

[@frequency_relative_interval = ] frequency_relative_interval

是每月中已调度合并频率间隔发生。frequency_relative_interval 的数据类型为 int,可以是下列值之一。

描述
1 第一个
2
4 第三个
8 第四个
16 最后一个
NULL(默认值)  

[@frequency_recurrence_factor = ] frequency_recurrence_factor

frequency_type 使用的重复因子。frequency_recurrence_factor 的数据类型为 int,默认设置为 NULL。

[@frequency_subday = ] frequency_subday

freq_subday_interval 的单位。frequency_subday 的数据类型为 int,可以是下列值之一。

描述
1 一次
2
4 分钟
8 小时
NULL(默认值)  

[@frequency_subday_interval = ] frequency_subday_interval

是各合并间 frequency_subday 发生的频率。frequency_subday_interval 的数据类型为 int,默认设置为 NULL。

[@active_start_time_of_day = ] active_start_time_of_day

是第一次调度合并代理程序的时间,格式为 HHMMSS。active_start_time_of_day 的数据类型为 int,默认设置为 NULL。

[@active_end_time_of_day = ] active_end_time_of_day

是停止调度合并代理程序的时间,格式为 HHMMSS。active_end_time_of_day 的数据类型为 int,默认设置为 NULL。

[@active_start_date = ] active_start_date

是第一次调度合并代理程序的日期,格式为 YYYYMMDD。active_start_date 的数据类型为 int,默认设置为 NULL。

[@active_end_date = ] active_end_date

是停止调度合并代理程序的日期,格式为 YYYYMMDD。active_end_date 的数据类型为 int,默认设置为 NULL。

[@optional_command_line = ] 'optional_command_line'

是要执行的可选命令提示符。optional_command_line 的数据类型为 nvarchar(4000),默认设置为 NULL。该参数用于添加捕获输出并将其保存到文件中的命令,或者用于指定配置文件或特性。

[@description = ] 'description'

是对该合并订阅的简短描述。description 的数据类型为 nvarchar(255),默认设置为 NULL。

[@enabled_for_syncmgr = ] 'enabled_for_syncmgr'

指定是否可通过 Microsoft Windows 同步管理器对订阅进行同步处理。enabled_for_syncmgr 的数据类型为 nvarchar(5),默认设置为 FALSE。如果是 false,则表示该订阅没有注册到同步管理器上。如果是 true,则表示该订阅已注册到同步管理器上,可以在不启动 SQL Server 企业管理器的情况下进行同步处理。

[@offloadagent = ] remote_agent_activation

指定可以远程地激活代理程序。remote_agent_activationis 的数据类型为 bit,默认设置为 0。0 指定不能远程地激活代理程序。而 1 指定将远程地激活代理程序,并且是在 remote_agent_server_name 所指定的远程计算机上激活。

[@offloadserver = ] 'remote_agent_server_name'

指定用于远程代理程序激活的服务器的网络名称。remote_agent_server_name 的数据类型为 sysname,默认设置为 NULL。

[@use_interactive_resolver = ] 'use_interactive_resolver'

允许交互式地解决所有允许交互式地解决的项目的冲突。use_interactive_resolver 的数据类型为 nvarchar(5),默认设置为 FALSE。

[@merge_job_name = ] 'merge_job_name'

仅限内部使用。

返回代码值

0(成功)或 1(失败)

注释

sp_addmergesubscription 用于合并复制。

权限

只有 sysadmin 固定服务器角色成员或 db_owner 固定数据库角色成员才能执行 sp_addmergesubscription

请参见

交互式冲突解决程序

sp_changemergesubscription

sp_dropmergesubscription

sp_helpmergesubscription

系统存储过程