共用方式為


設定合併式發行集的相容性層級

本主題描述如何使用 SQL Server Management Studio 或 Transact-SQL,在 SQL Server 2014 中設定合併式發行集的相容性層級。 合併式複寫會使用發行集相容性層級來判斷指定資料庫中的發行集可以使用哪些功能。

本主題內容

使用 SQL Server Management Studio

在 [新增發行集精靈] 的 [ 訂閱者類型 ] 頁面上設定兼容性層級。 如需存取此精靈的詳細資訊,請參閱 建立發行集。 建立快照之後,可以提高相容性層級,但無法降低。 在 [發行集屬性 - <發行集>] 對話框的 [一般] 頁面上增加兼容性層級。 如需有關存取這個對話方塊的詳細資訊,請參閱< View and Modify Publication Properties>。 如果您提高發行集的相容性層級,則任何在相容性層級以下版本伺服器上的現有訂閱將無法再同步。

備註

因為相容性層級會影響其他發行屬性及哪些文章屬性是有效的,因此請勿在使用同一對話框時同時變更相容性層級和其他屬性。 在屬性變更之後,應該重新產生發行物的快照。

設定出版相容性層級

  • 在 [新增發行集精靈] 的 [ 訂閱者類型 ] 頁面上,選取發行集應該支援的訂閱者類型。

增加發行集相容性層級

  • 在 [發行集屬性 - <發行集>] 對話方塊的 [一般] 頁面上,選取 [相容性層級]。

使用 Transact-SQL

合併式發行集的相容性層級可以在稍後建立或修改發行集時以程序設計方式設定。 您可以使用復寫預存程式來設定或變更此發行集屬性。

若要設定合併式發行集的發行集相容性層級

  1. 在發行者上,執行 sp_addmergepublication (Transact-SQL),指定 @publication_compatibility_level 的值,讓發行集與舊版的 Microsoft SQL Server 相容。 如需詳細資訊,請參閱建立出版物

變更合併式發行集的發行集相容性層級

  1. 執行sp_changemergepublication (Transact-SQL),指定publication_compatibility_level@property,並為@value指定適當的發行集相容性層級。

判斷合併式發行集的發行集相容性層級

  1. 執行 sp_helpmergepublication(Transact-SQL),並指定所需的出版物。

  2. 找出結果集 backward_comp_level 欄中的發行集相容性層級。

範例 (Transact-SQL)

此範例會建立合併式發行集,並設定發行集相容性層級。

-- To avoid storing the login and password in the script file, the values   
-- are passed into SQLCMD as scripting variables. For information about   
-- how to use scripting variables on the command line and in SQL Server  
-- Management Studio, see the "Executing Replication Scripts" section in  
-- the topic "Programming Replication Using System Stored Procedures".  
  
--Add a new merge publication.  
DECLARE @publicationDB AS sysname;  
DECLARE @publication AS sysname;  
DECLARE @login AS sysname;  
DECLARE @password AS sysname;  
SET @publicationDB = N'AdventureWorks2012';   
SET @publication = N'AdvWorksSalesOrdersMerge'   
SET @login = $(Login);  
SET @password = $(Password);  
  
-- Create a new merge publication.   
USE [AdventureWorks2012]  
EXEC sp_addmergepublication   
@publication = @publication,   
-- Set the compatibility level to SQL Server 2014.  
@publication_compatibility_level = '120RTM';   
  
-- Create the snapshot job for the publication.  
EXEC sp_addpublication_snapshot   
@publication = @publication,  
@job_login = @login,  
@job_password = @password;  
GO  

本範例會變更合併式發行集的發行集相容性層級。

備註

如果發行集使用任何需要特定相容性層級的功能,則可能無法變更發行集相容性層級。 如需詳細資訊,請參閱 復寫回溯相容性

DECLARE @publication AS sysname;  
SET @publication = N'AdvWorksSalesOrdersMerge' ;  
  
-- Change the publication compatibility level to   
-- SQL Server 2012.  
EXEC sp_changemergepublication   
@publication = @publication,   
@property = N'publication_compatibility_level',   
@value = N'110RTM';  
GO  
  

這個範例會傳回合併出版物目前的相容性層級。

DECLARE @publication AS sysname;  
SET @publication = N'AdvWorksSalesOrdersMerge' ;  
EXEC sp_helpmergepublication   
@publication = @publication;  
GO  
  

另請參閱

創建出版物