sp_changesubstatus (Transact-SQL)
更改现有订阅服务器的状态。 此存储过程在发布服务器上对发布数据库执行。
语法
sp_changesubstatus [ [ @publication = ] 'publication' ]
[ , [ @article = ] 'article' ]
[ , [ @subscriber = ] 'subscriber' ]
, [ @status = ] 'status'
[ , [ @previous_status = ] 'previous_status' ]
[ , [ @destination_db = ] 'destination_db' ]
[ , [ @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' ]
[ , [ @distribution_jobid = ] distribution_jobid ]
[ , [ @from_auto_sync = ] from_auto_sync ]
[ , [ @ignore_distributor = ] ignore_distributor ]
[ , [ @offloadagent= ] remote_agent_activation ]
[ , [ @offloadserver= ] 'remote_agent_server_name' ]
[ , [ @dts_package_name= ] 'dts_package_name' ]
[ , [ @dts_package_password= ] 'dts_package_password' ]
[ , [ @dts_package_location= ] dts_package_location ]
[ , [ @skipobjectactivation = ] skipobjectactivation
[ , [ @distribution_job_name= ] 'distribution_job_name' ]
[ , [ @publisher = ] 'publisher' ]
参数
[ @publication = ] 'publication'
发布的名称。 publication 为 sysname,默认值为 %. 如果未 指定发布 ,则所有发布都会受到影响。
[ @article = ] 'article'
项目的名称。 该名称对发布必须是唯一的。 article 为 sysname,默认值为 %. 如果未 指定项目 ,则所有项目都会受到影响。
[ @subscriber = ] 'subscriber'
要更改其状态的订阅服务器的名称。 订阅服务器 为 sysname,默认值为 %. 如果未 指定订阅服务器,则所有订阅服务器 的状态将更改为指定项目。
[ @status = ] 'status'
syssubscriptions 表中的订阅状态。 status 为 sysname,没有默认值,可以是以下值之一。
值 | 说明 |
---|---|
active | 订阅服务器已被同步并且正在接收数据。 |
inactive | 存在订阅服务器项,但没有订阅。 |
订阅 | 订阅服务器正在请求数据,但尚未同步。 |
[ @previous_status = ] 'previous_status'
订阅的以前状态。 previous_status为 sysname,默认值为 NULL。 此参数允许更改当前具有该状态的任何订阅,从而允许对特定订阅集使用组函数(例如,将所有活动订阅重新设置为 已订阅)。
[ @destination_db = ] 'destination_db'
目标数据库的名称。 destination_db为 sysname,默认值为 %.
[ @frequency_type = ] frequency_type
计划分发任务的频率。 frequency_type为 int,默认值为 NULL。
[ @frequency_interval = ] frequency_interval
要应用于frequency_type设置的频率的值。 frequency_interval为 int,默认值为 NULL。
[ @frequency_relative_interval = ] frequency_relative_interval
分发任务的日期。 当frequency_type设置为 32(每月相对)时,将使用此参数。 frequency_relative_interval 为 int,可以是以下值之一。
值 | 说明 |
---|---|
1 | 第一个 |
2 | Second |
4 | 第三个 |
8 | 第四 |
16 | Last |
NULL(默认值) |
[ @frequency_recurrence_factor = ] frequency_recurrence_factor
frequency_type使用的重复因子。 frequency_recurrence_factor为 int,默认值为 NULL。
[ @frequency_subday = ] frequency_subday
在定义的时间段内重新安排的频率(以分钟为单位)。 frequency_subday为 int,可以是其中一个值。
值 | 说明 |
---|---|
1 | 一次 |
2 | Second |
4 | Minute |
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。
[ @distribution_jobid = ] distribution_jobid
将订阅状态从非活动更改为活动状态时,订阅的分发服务器上分发代理的作业 ID。 在其他情况下,不定义该参数。 如果对此存储过程的单个调用中涉及多个分发代理,则不定义结果。 distribution_jobid为 binary(16),默认值为 NULL。
[ @from_auto_sync = ] from_auto_sync
标识为仅供参考。 不支持。 不保证以后的兼容性。
[ @ignore_distributor = ] ignore_distributor
标识为仅供参考。 不支持。 不保证以后的兼容性。
[ @offloadagent = ] remote_agent_activation
注意
已不推荐使用远程代理激活,也不再支持该功能。 支持此参数只是为了让脚本能够向后兼容。 将remote_agent_activation设置为 0 以外的值将生成错误。
[ @offloadserver = ] 'remote_agent_server_name'
注意
已不推荐使用远程代理激活,也不再支持该功能。 支持此参数只是为了让脚本能够向后兼容。 将 remote_agent_server_name 设置为任何非 NULL 值将生成错误。
[ @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是默认为 NULL 的 sysname,它指定密码属性将保持不变。
注意
DTS 包必须具有密码。
[ @dts_package_location = ] dts_package_location
指定包位置。 dts_package_location为 int,默认值为 0。 如果 为 0,则包位置位于分发服务器上。 如果 为 1,则包位置位于订阅服务器上。 包的位置可以是 分发服务器 或 订阅服务器。
[ @skipobjectactivation = ] skipobjectactivation
标识为仅供参考。 不支持。 不保证以后的兼容性。
[ @distribution_job_name = ] 'distribution_job_name'
分发作业的名称。 distribution_job_name为 sysname,默认值为 NULL。
[ @publisher = ] 'publisher'
指定非 Microsoft SQL Server 发布服务器。 publisher 为 sysname,默认值为 NULL。
注意
更改 SQL Server 发布服务器上的项目属性时,不应使用 publisher 。
返回代码值
0 (成功) 或 1 (失败)
注解
sp_changesubstatus用于快照 副本 (replica)和事务副本 (replica)。
sp_changesubstatus更改状态的 syssubscriptions 表中订阅服务器的状态。 如果需要,它会更新 sysarticles 表中的项目状态以指示活动或非活动状态。 如果需要,它会在 副本 (replica)ted 表的 sysobjects 表中设置副本 (replica)tion 标志。
权限
只有 sysadmin 固定服务器角色、db_owner固定数据库角色的成员或订阅的创建者才能执行sp_changesubstatus。
另请参阅
sp_addsubscription (Transact-SQL)
sp_dropsubscription (Transact-SQL)
sp_helpdistributor (Transact-SQL)
sp_helpsubscription (Transact-SQL)
系统存储过程 (Transact-SQL)
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈