将请求订阅的代理程序添加到合并发布。此存储过程在订阅服务器的订阅数据库上执行。
sp_addmergepullsubscription_agent [ [ @name = ] 'name' ]
,
[ @publisher = ] 'publisher'
,
[ @publisher_db = ] 'publisher_db'
,
[ @publication = ] 'publication '
[ , [ @publisher_security_mode = ] publisher_security_mode ]
[ , [ @publisher_login = ] 'publisher_login' ]
[ , [ @publisher_password = ] 'publisher_password' ]
[ , [ @publisher_encrypted_password = ] publisher_encrypted_password ]
[ , [ @subscriber = ] 'subscriber' ]
[ , [ @subscriber_db = ] 'subscriber_db' ]
[ , [ @subscriber_security_mode = ] subscriber_security_mode ]
[ , [ @subscriber_login = ] 'subscriber_login' ]
[ , [ @subscriber_password = ] 'subscriber_password' ]
[ , [ @distributor = ] 'distributor' ]
[ , [ @distributor_security_mode = ] distributor_security_mode ]
[ , [ @distributor_login = ] 'distributor_login' ]
[ , [ @distributor_password = ] 'distributor_password' ]
[ , [ @encrypted_password = ] encrypted_password ]
[ , [ @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' ]
[ , [ @merge_jobid = ] merge_jobid ]
[ , [ @enabled_for_syncmgr = ] 'enabled_for_syncmgr' ]
[ , [ @ftp_address = ] 'ftp_address' ]
[ , [ @ftp_port = ] ftp_port ]
[ , [ @ftp_login = ] 'ftp_login' ]
[ , [ @ftp_password = ] 'ftp_password' ]
[ , [ @alt_snapshot_folder = ] 'alternate_snapshot_folder' ]
[ , [ @working_directory = ] 'working_directory' ]
[ , [ @use_ftp= ] 'use_ftp' ]
[ , [ @reserved= ] 'reserved' ]
[ , [ @use_interactive_resolver = ] 'use_interactive_resolver' ]
[ , [ @offloadagent = ] 'remote_agent_activation' ]
[ , [ @offloadserver = ] 'remote_agent_server_name' ]
[ , [ @job_name = ] 'job_name' ]
[ , [ @dynamic_snapshot_location= ] 'dynamic_snapshot_location' ]
[@name = ] 'name'
是代理程序名。name 的数据类型为 sysname,默认设置为 NULL。
[@publisher = ] 'publisher'
是发布服务器名。publisher 的数据类型为 sysname,没有默认设置。
[@publisher_db = ] 'publisher_db'
是发布服务器数据库名。publisher_db 的数据类型为 sysname,没有默认设置。
[@publication = ] 'publication'
是发布名。publication 的数据类型为 sysname,没有默认设置。
[@publisher_security_mode = ] publisher_security_mode
是在同步时用于连接到发布服务器的安全模式。publisher_security_mode 的数据类型为 int,默认设置为 1。如果该设置为 0,则指定 SQL Server 身份验证。如果该设置为 1,则指定 Windows 身份验证。
[@publisher_login = ] 'publisher_login'
是在同步时用于连接到发布服务器的登录。publisher_login 的数据类型为 sysname,默认设置为 NULL。
[@publisher_password = ] 'publisher_password'
是用于连接到发布服务器的密码。publisher_password 的数据类型为 sysname,默认设置为 NULL。
[@publisher_encrypted_password = ] publisher_encrypted_password
指定是否以加密格式存储密码。publisher_encrypted_password 的数据类型为 bit,默认设置为 0。
[@subscriber = ] 'subscriber'
是订阅服务器名。subscriber 的数据类型为 sysname,默认设置为 NULL。
[@subscriber_db = ] 'subscriber_db'
是订阅数据库名称。subscriber_db 的数据类型为 sysname,默认设置为 NULL。
[@subscriber_security_mode = ] subscriber_security_mode
是在同步时用于连接到订阅服务器的安全模式。subscriber_security_mode 的数据类型为 int,默认设置为 NULL。如果该设置为 0,则指定 SQL Server 身份验证。如果该设置为 1,则指定 Windows 身份验证。
[@subscriber_login = ] 'subscriber_login'
是在同步时用于连接到订阅服务器的订阅服务器登录。如果将 subscriber_security_mode 设置为 0,则必需 subscriber_login。subscriber_login 的数据类型为 sysname,默认设置为 NULL。
[@subscriber_password = ] 'subscriber_password'
是订阅服务器密码。如果 subscriber_security_mode 设置为 0,则必需 subscriber_password。subscriber_password 的数据类型为 sysname,默认设置为 NULL。如果使用订阅服务器密码,则将自动加密该密码。
[@distributor = ] 'distributor'
是分发服务器名。distributor 的数据类型为 sysname,默认设置为 publisher,这表示发布服务器也是分发服务器。
[@distributor_security_mode = ] distributor_security_mode
是在同步时用于连接到分发服务器的安全模式。distributor_security_mode 的数据类型为 int,默认设置为 0。0 指定 SQL Server 身份验证。1 指定 Windows 身份验证。
[@distributor_login = ] 'distributor_login'
是在同步时用于连接到分发服务器的分发服务器登录。如果将 distributor_security_mode 设置为 0,则必需 distributor_login。distributor_login 的数据类型为 sysname,默认设置为 NULL。
[@distributor_password = ] 'distributor_password'
是分发服务器密码。如果 distributor_security_mode 设置为 0,则必需 distributor_password。distributor_password 的数据类型为 sysname,默认设置为 NULL。
[@encrypted_password = ] encrypted_password
指定是否加密分发服务器密码。encrypted_password 的数据类型为 bit,默认设置为 0。这用于生成复制脚本。
[@frequency_type = ] frequency_type
是调度合并代理程序所用的频率。frequency_type 的数据类型为 int,可以是下列值之一。
值 | 描述 |
---|---|
1 | 一次 |
2 | 按需 |
4 | 每天 |
8 | 每周 |
16 | 每月 |
32 | 每月相对信息 |
64 | 自动启动 |
124 | 反复出现 |
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_type 设置为 32(每月相对信息)时使用该参数。frequency_relative_interval 的数据类型为 int,可以是下列值之一。
值 | 描述 |
---|---|
1 | 第一个 |
2 | 秒 |
4 | 第三个 |
8 | 第四个 |
16 | 最后一个 |
NULL(默认值) |
[@frequency_recurrence_factor = ] frequency_recurrence_factor
是 frequency_type 使用的重复因子。frequency_recurrence_factor 的数据类型为 int,默认设置为 0。
[@frequency_subday = ] frequency_subday
是在定义的周期内重新调度的频率。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'
是提供给合并代理程序的可选命令提示符。例如,-DefinitionFile C:\Distdef.txt 或 -CommitBatchSize 10。optional_command_line 的数据类型为 nvarchar(255),默认设置为 ''。
[@merge_jobid = ] merge_jobid
是作业 ID 的输出参数。merge_jobid 的数据类型为 binary(16),默认设置为 NULL。
[@enabled_for_syncmgr = ] 'enabled_for_syncmgr'
指定能否通过 Windows 同步管理器对订阅进行同步处理。enabled_for_syncmgr 的数据类型为 nvarchar(5),默认设置为 FALSE。如果是 false,则表示该订阅没有注册到同步管理器上。如果是 true,则表示该订阅已注册到同步管理器上,可以在不启动 SQL Server 企业管理器的情况下进行同步处理。
[@ftp_address = ] 'ftp_address'
仅为保持向后兼容性。
[@ftp_port = ] ftp_port
仅为保持向后兼容性。
[@ftp_login = ] 'ftp_login'
仅为保持向后兼容性。
[@ftp_password = ] 'ftp_password'
仅为保持向后兼容性。
[@alt_snapshot_folder = ] 'alternate_snapshot_folder'
指定获取快照文件的位置。alternate_snapshot_folder 的数据类型为 nvarchar(255),默认设置为 NULL。如果为 NULL,则将从发布服务器指定的默认位置获取快照文件。
[@working_directory = ] 'working_directory'
是在通过 FTP 传输快照文件时用于临时存储发布的数据和架构文件的工作目录名。working_directory 的数据类型为 nvarchar(255),默认设置为 NULL。
[@use_ftp = ] 'use_ftp'
指定使用 FTP 而是典型协议来检索快照。use_ftp 的数据类型为 nvarchar(5),默认设置为 FALSE。
[@reserved = ] 'reserved'
仅限内部使用。
[@use_interactive_resolver = ] 'use_interactive_resolver' ]
使用交互式冲突解决程序解决所有允许交互解决的项目的冲突。use_interactive_resolver 的数据类型为 nvarchar(5),默认设置为 FALSE。
[@offloadagent = ] 'remote_agent_activation'
指定可以远程激活代理程序。remote_agent_activation 的数据类型为 nvarchar(5),默认设置为 FALSE。false 指定不能远程地激活代理程序。true 指定将远程激活代理程序,并且是在 remote_agent_server_name 所指定的远程计算机上激活。
[@offloadserver = ] 'remote_agent_server_name'
指定用于远程代理程序激活的服务器的网络名称。remote_agent_server_name 的数据类型为 sysname,默认设置为 NULL。
[@job_name = ] 'job_name' ]
仅限内部使用。
[@dynamic_snapshot_location = ] 'dynamic_snapshot_location' ]
在使用动态快照时将要读取的快照文件所在的文件夹路径。dynamic_snapshot_location 的数据类型为 nvarchar(260),默认设置为 NULL。
0(成功)或 1(失败)
sp_addmergepullsubscription_agent 用于合并复制,并使用与 sp_addsubsubscriber_agent 相似的功能。
只有 sysadmin 固定服务器角色成员或 db_owner 固定数据库角色成员才能执行 sp_addmergepullsubscription_agent。
相关文章