sp_replicationdboption (Transact-SQL)sp_replicationdboption (Transact-SQL)

本主題適用於:是SQL Server (從 2008 開始)否Azure SQL Database否Azure SQL 資料倉儲 否平行處理資料倉儲 THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

設定指定資料庫的複寫資料庫選項。Sets a replication database option for the specified database. 這個預存程序執行於任何資料庫的發行者端或訂閱者端。This stored procedure is executed at the Publisher or Subscriber on any database.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions


sp_replicationdboption [ @dbname= ] 'db_name'   
        , [ @optname= ] 'optname'   
        , [ @value= ] 'value'   
    [ , [ @ignore_distributor= ] ignore_distributor ]  
    [ , [ @from_scripting = ] from_scripting ]  


[@dbname=] 'dbname'[@dbname=] 'dbname'
這是要設定複寫資料庫選項的資料庫。Is the database for which the replication database option is being set. db_namesysname,沒有預設值。db_name is sysname, with no default.

[@optname=] 'optname'[@optname=] 'optname'
這是要啟用或停用的複寫資料庫選項。Is the replication database option to enable or disable. optnamesysname,而且可以是下列值之一。optname is sysname, and can be one of these values.

ValueValue DescriptionDescription
合併式發行merge publish 可用於合併式發行集的資料庫。Database can be used for merge publications.
發行publish 資料庫可用於其他類型的發行集。Database can be used for other types of publications.
訂閱subscribe 資料庫是訂閱資料庫。Database is a subscription database.
與備份同步sync with backup 啟用資料庫的協調備份。Database is enabled for coordinated backup. 如需詳細資訊,請參閱異動複寫啟用協調備份(Replication TRANSACT-SQL Programming)For more information, see Enable Coordinated Backups for Transactional Replication (Replication Transact-SQL Programming).

[ @value=] ''[ @value=] 'value'
這是指要啟用或停用給定的複寫資料庫選項。Is whether to enable or disable the given replication database option. sysname,而且可以是truefalsevalue is sysname, and can be true or false. 當這個值是falseoptname合併式發行,也會卸除合併發行資料庫的訂閱。When this value is false and optname is merge publish, subscriptions to the merge published database are also dropped.

[ @ignore_distributor=] ignore_distributor[ @ignore_distributor=] ignore_distributor
指出是否在未連接到散發者的情況之下,執行這個預存程序。Indicates whether this stored procedure is executed without connecting to the Distributor. ignore_distributor,預設值是0,表示散發者應該連接到並更新與發行集資料庫的新狀態。ignore_distributor is bit, with a default of 0, meaning the Distributor should be connected to and updated with the new status of the publishing database. 1才應該指定 「 散發者 」 是否無法存取和sp_replicationdboption正用來停用發行。The value 1 should be specified only if the Distributor is inaccessible and sp_replicationdboption is being used to disable publishing.

[ @from_scripting=] from_scripting[ @from_scripting=] from_scripting
僅供參考之用。Identified for informational purposes only. 不支援。Not supported. 我們無法保證未來的相容性。Future compatibility is not guaranteed.

傳回碼值Return Code Values

0 (成功) 或1 (失敗)0 (success) or 1 (failure)


sp_replicationdboption用於快照式複寫、 異動複寫和合併式複寫。sp_replicationdboption is used in snapshot replication, transactional replication, and merge replication.

隨著給定的選項而不同,這個程序會建立或卸除特定複寫系統資料表、安全性帳戶等。This procedure creates or drops specific replication system tables, security accounts, and so on, depending on the options given. 設定對應的分類中的位元master.sysdatabases系統資料表,並建立必要的系統資料表。Sets the corresponding category bit in the master.sysdatabases system table and creates the necessary system tables.

若要停用發行,發行集資料庫必須在線上。To disable publishing, the publication database must be online. 如果發行集資料庫的資料庫快照集存在,您必須先卸除它,才能停用發行。If a database snapshot exists for the publication database, it must be dropped before disabling publishing. 資料庫快照集是資料庫的唯讀離線複本,與複寫快照集無關。A database snapshot is a read-only offline copy of a database, and is not related to a replication snapshot. 如需詳細資訊,請參閱資料庫快照集 (SQL Server)For more information, see Database Snapshots (SQL Server).


只有成員sysadmin固定的伺服器角色可以執行sp_replicationdboptionOnly members of the sysadmin fixed server role can execute sp_replicationdboption.

另請參閱See Also

設定發行和散發 Configure Publishing and Distribution
Create a Publication Create a Publication
刪除發行集 Delete a Publication
停用發行和散發 Disable Publishing and Distribution
sys.sysdatabases (Transact SQL) sys.sysdatabases (Transact-SQL)
複寫預存程序 (Transact-SQL)Replication Stored Procedures (Transact-SQL)