添加新的代理程序到订阅服务器数据库。此存储过程在订阅服务器的订阅数据库上执行。
sp_addpullsubscription_agent [ @publisher = ] 'publisher'
,
[ @publisher_db = ] 'publisher_db'
,
[ @publication = ] 'publication '
[ , [ @subscriber = ] 'subscriber' ]
[ , [ @subscriber_db = ] 'subscriber_db' ]
[ , [ @subscriber_security_mode = ] subscriber_security_mode ]
[ , [ @subscriber_login = ] 'subscriber_login' ]
[ , [ @subscriber_password = ] 'subscriber_password' ]
[ , [ @distributor = ] 'distributor' ]
[ , [ @distribution_db = ] 'distribution_db' ]
[ , [ @distributor_security_mode = ] distributor_security_mode ]
[ , [ @distributor_login = ] 'distributor_login' ]
[ , [ @distributor_password = ] 'distributor_password' ]
[ , [ @optional_command_line = ] 'optional_command_line' ]
[ , [ @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 ]
[ , [ @distribution_jobid = ] distribution_jobid OUTPUT ]
[ , [ @encrypted_distributor_password = ] encrypted_distributor_password ]
[ , [ @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' ]
[ , [ @publication_type= ] publication_type ]
[ , [ @dts_package_name = ] 'dts_package_name' ]
[ , [ @dts_package_password = ] 'dts_package_password' ]
[ , [ @dts_package_location = ] 'dts_package_location' ]
[ , [ @reserved= ] 'reserved' ]
[ , [ @offloadagent = ] 'remote_agent_activation' ]
[ , [ @offloadserver = ] 'remote_agent_server_name' ]
[ , [ @job_name = ] 'job_name' ]
[@publisher = ] 'publisher'
是发布服务器名。publisher 的数据类型为 sysname,没有默认设置。
[@publisher_db = ] 'publisher_db'
是发布服务器数据库名。publisher_db 的数据类型为 sysname,没有默认设置。
[@publication = ] 'publication'
是发布名。publication 的数据类型为 sysname,没有默认设置。
[@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 指定 Microsoft SQL Server 身份验证。1 指定 Microsoft Windows 身份验证。
[@subscriber_login = ] '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 指定。
[ @distribution_db = ] 'distribution_db'
是分发服务器名。distribution_db 的数据类型为 sysname,没有默认设置。
[@distributor_security_mode = ] distributor_security_mode
是在同步时用于连接到分发服务器的安全模式。distributor_security_mode 的数据类型为 int,默认设置为 0。0 指定 Microsoft SQL Server 身份验证。1 指定 Microsoft Windows 身份验证。
[@distributor_login = ] 'distributor_login'
是在同步时用于连接到分发服务器的分发服务器登录。如果 distributor_security_mode 设置为 0,则需要 distributor_login。distributor_login 的数据类型为 sysname,默认设置为 sa。
[@distributor_password = ] 'distributor_password'
是分发服务器密码。如果 distributor_security_mode 设置为 0,则必需 distributor_password。distributor_password 的数据类型为 sysname,默认设置为 NULL。
[@optional_command_line = ] 'optional_command_line'
是提供给分发代理程序的可选命令提示符。例如,-DefinitionFile C:\Distdef.txt 或 -CommitBatchSize 10。optional_command_line 的数据类型为 nvarchar(4000),默认设置为空字符串。
[@frequency_type = ] frequency_type
是调度分发代理程序所用的频率。frequency_type 的数据类型为 int,可以是下列值之一。
值 | 描述 |
---|---|
1 | 一次 |
2(默认值) | 按需 |
4 | 每天 |
8 | 每周 |
16 | 每月 |
32 | 每月相对信息 |
64 | 自动启动 |
124 | 反复出现 |
[@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,默认设置为 1。
[@frequency_subday = ] frequency_subday
是在定义的周期内重新调度的频率。frequency_subday 的数据类型为 int,可以是下列值之一。
值 | 描述 |
---|---|
1(默认值) | 一次 |
2 | 秒 |
4 | 分钟 |
8 | 小时 |
[@frequency_subday_interval = ] frequency_subday_interval
是 frequency_subday 的间隔。frequency_subday_interval 的数据类型为 int,默认设置为 1。
[@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,默认设置为 0。
[@active_start_date = ] active_start_date
是第一次调度分发代理程序的日期,格式为 YYYYMMDD。active_start_date 的数据类型为 int,默认设置为 0。
[@active_end_date = ] active_end_date
是停止调度分发代理程序的日期,格式为 YYYYMMDD。active_end_date 的数据类型为 int,默认设置为 0。
[@distribution_jobid = ] distribution_jobid OUTPUT
是该作业的分发代理程序 ID。distribution_jobid 的数据类型为 binary(16),默认设置为 NULL,并且该参数是 OUTPUT 参数。
[@encrypted_distributor_password = ] encrypted_distributor_password
仅限内部使用。
[@enabled_for_syncmgr = ] 'enabled_for_syncmgr'
表示是否可以通过 Microsoft 同步管理器对订阅进行同步处理。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。
[@working_directory = ] 'working_director'
是用于存储发布的数据和架构文件的工作目录名。working_directory 的数据类型为 nvarchar(255),默认设置为 NULL。应将该名称指定为 UNC 格式。
[@use_ftp = ] 'use_ftp'
指定使用 FTP 而不使用常规协议检索快照。use_ftp 的数据类型为 nvarchar(5),默认设置为 FALSE。
[@publication_type = ] publication_type
指定发布的复制类型。publication_type 的数据类型为 tinyint,默认设置为 0。如果是 0,则发布是事务类型。如果是 1,则表示发布是快照类型。如果是 2,则表示发布是合并类型。
[@dts_package_name = ] 'dts_package_name'
指定 DTS 包的名称。dts_package_name 的数据类型为 sysname,默认设置为 NULL。例如,若要指定 DTSPub_Package 包,则该参数将是 @dts_package_name = N'DTSPub_Package'。
[@dts_package_password = ] 'dts_package_password'
指定如果有密码,则密码在包上。dts_package_password 的数据类型为 sysname,默认设置为 NULL,表示密码不在包上。
[@dts_package_location = ] 'dts_package_location'
指定包的位置。dts_package_location 的数据类型为 nvarchar(12),默认设置为 SUBSCRIBER。包的位置可以是 distributor 或 subscriber。
[@reserved = ] 'reserved'
仅限内部使用。
[@offloadagent = ] 'remote_agent_activation'
指定可以远程地激活代理程序。remote_agent_activation 的数据类型为 bit,默认设置为 0。0 指定不能远程地激活代理程序。而 1 指定将远程地激活代理程序,并且是在 remote_agent_server_name 所指定的远程计算机上激活。
[@offloadserver = ] 'remote_agent_server_name'
指定用于远程激活的服务器的网络名。remote_agent_server_name 的数据类型为 sysname,默认设置为 NULL。
[@job_name = ] 'job_name'
仅限内部使用。
0(成功)或 1(失败)
sp_addpullsubscription_agent 用于快照复制和事务复制。
只有 sysadmin 固定服务器角色成员或 db_owner 固定数据库角色成员才能执行 sp_addpullsubscription_agent。