如何:設定合併式發行集的相容性層級 (複寫 Transact-SQL 程式設計)

合併式發行集的相容性層級可以在建立發行集時以程式設計方式加以設定,或是在之後以程式設計方式加以修改。您可以使用複寫預存程序來設定或變更此發行集屬性。如需有關發行集相容性層級與相關限制和需求的詳細資訊,請參閱<在複寫拓撲中使用多個 SQL Server 版本>主題中的<合併式發行集的相容性層級>一節。

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

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

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

  1. 執行 sp_helpmergepublication (Transact-SQL),指定所要的發行集。

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

範例

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

-- 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'AdventureWorks2008R2'; 
SET @publication = N'AdvWorksSalesOrdersMerge' 
SET @login = $(Login);
SET @password = $(Password);

-- Create a new merge publication. 
USE [AdventureWorks2008R2]
EXEC sp_addmergepublication 
    @publication = @publication, 
    -- Set the compatibility level to SQL Server 2000 SP3.
    @publication_compatibility_level = '80RTM'; 

-- 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 2005.
EXEC sp_changemergepublication 
    @publication = @publication, 
    @property = N'publication_compatibility_level', 
    @value = N'90RTM'
GO

此範例會傳回合併式發行集的正確發行集相容性層級。

DECLARE @publication AS sysname
SET @publication = N'AdvWorksSalesOrdersMerge' 

EXEC sp_helpmergepublication 
    @publication = @publication;
GO