sp_mergearticlecolumn (Transact-SQL)

適用於:SQL Server

垂直分割合併式發行集。 這個預存程式會在發行集資料庫的發行者端執行。

Transact-SQL 語法慣例

語法

sp_mergearticlecolumn
    [ @publication = ] N'publication'
    , [ @article = ] N'article'
    [ , [ @column = ] N'column' ]
    [ , [ @operation = ] N'operation' ]
    [ , [ @schema_replication = ] N'schema_replication' ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
[ ; ]

引數

[ @publication = ] N'publication'

發行集的名稱。 @publication為 sysname,沒有預設值。

[ @article = ] N'article'

發行集中發行項的名稱。 @article為 sysname,沒有預設值。

[ @column = ] N'column'

識別要在其中建立垂直數據分割的數據行。 @column為 sysname,預設值為 NULL。 如果 NULL@operation 設定為 add,則源數據表中的所有數據行預設都會新增至發行項。 當 @operation 設定drop為 時,@column不能NULL。 若要從發行項中排除數據行,請執行sp_mergearticlecolumn並指定@column,並將 設定@operationdrop為 ,讓每個數據行從指定的@article中移除。

[ @operation = ] N'operation'

複寫狀態。 @operation為 nvarchar(4),預設值為 add

  • add 標記數據行以進行複寫。
  • drop 清除數據行。

[ @schema_replication = ] N'schema_replication'

指定在執行 合併代理程式 時傳播架構變更。 @schema_replication為 nvarchar(5),預設值為 false

false 支援 @schema_replication

[ @force_invalidate_snapshot = ] force_invalidate_snapshot

啟用或停用快照集失效的能力。 @force_invalidate_snapshot為 bit,預設值為 0

  • 0 指定合併發行項的變更不會造成快照集無效。

  • 1 指定合併發行項的變更可能會導致快照集無效,如果發生這種情況,則 值 1 會授與新快照集發生的許可權。

[ @force_reinit_subscription = ] force_reinit_subscription

啟用或停用重新初始化訂閱的功能。 @force_reinit_subscription為 bit,預設值為 0

  • 0 指定合併發行項的變更不會使訂閱重新初始化。

  • 1 指定合併發行項的變更可能會使訂閱重新初始化,如果發生這種情況,則會提供訂閱重新初始化許可權的值 1

傳回碼值

0 (成功)或 1 (失敗)。

備註

sp_mergearticlecolumn 用於合併式複寫。

如果使用自動識別範圍管理,就無法從發行項卸除識別數據行。 如需詳細資訊,請參閱複寫識別資料欄

如果應用程式在建立初始快照集之後設定新的垂直分割區,則必須產生新的快照集並重新套用至每個訂用帳戶。 下一個排程的快照集和散發或合併代理程序執行時,會套用快照集。

如果使用資料列追蹤執行衝突偵測 (預設值),基底資料表最多可以包含 1,024 個資料行,但必須從發行項篩選資料行,以便發行最多 246 個資料行。 如果使用資料行追蹤,則基底資料表可包括的資料行數上限為 246。

範例

DECLARE @publication AS sysname;
DECLARE @table1 AS sysname;
DECLARE @table2 AS sysname;
DECLARE @table3 AS sysname;
DECLARE @salesschema AS sysname;
DECLARE @hrschema AS sysname;
DECLARE @filterclause AS nvarchar(1000);
SET @publication = N'AdvWorksSalesOrdersMerge'; 
SET @table1 = N'Employee'; 
SET @table2 = N'SalesOrderHeader'; 
SET @table3 = N'SalesOrderDetail'; 
SET @salesschema = N'Sales';
SET @hrschema = N'HumanResources';
SET @filterclause = N'Employee.LoginID = HOST_NAME()';

-- Add a filtered article for the Employee table.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table1, 
  @source_object = @table1, 
  @type = N'table', 
  @source_owner = @hrschema,
  @schema_option = 0x0004CF1,
  @description = N'article for the Employee table',
  @subset_filterclause = @filterclause;

-- Add an article for the SalesOrderHeader table that is filtered
-- based on Employee and horizontally filtered.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table2, 
  @source_object = @table2, 
  @type = N'table', 
  @source_owner = @salesschema, 
  @vertical_partition = N'true',
  @schema_option = 0x0034EF1,
  @description = N'article for the SalesOrderDetail table';

-- Add an article for the SalesOrderDetail table that is filtered
-- based on SaledOrderHeader.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table3, 
  @source_object = @table3, 
  @source_owner = @salesschema,
  @description = 'article for the SalesOrderHeader table', 
  @identityrangemanagementoption = N'auto', 
  @pub_identity_range = 100000, 
  @identity_range = 100, 
  @threshold = 80,
  @schema_option = 0x0004EF1;

-- Add all columns to the SalesOrderHeader article.
EXEC sp_mergearticlecolumn 
  @publication = @publication, 
  @article = @table2, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Remove the credit card Approval Code column.
EXEC sp_mergearticlecolumn 
  @publication = @publication, 
  @article = @table2, 
  @column = N'CreditCardApprovalCode', 
  @operation = N'drop', 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Add a merge join filter between Employee and SalesOrderHeader.
EXEC sp_addmergefilter 
  @publication = @publication, 
  @article = @table2, 
  @filtername = N'SalesOrderHeader_Employee', 
  @join_articlename = @table1, 
  @join_filterclause = N'Employee.BusinessEntityID = SalesOrderHeader.SalesPersonID', 
  @join_unique_key = 1, 
  @filter_type = 1, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Add a merge join filter between SalesOrderHeader and SalesOrderDetail.
EXEC sp_addmergefilter 
  @publication = @publication, 
  @article = @table3, 
  @filtername = N'SalesOrderDetail_SalesOrderHeader', 
  @join_articlename = @table2, 
  @join_filterclause = N'SalesOrderHeader.SalesOrderID = SalesOrderDetail.SalesOrderID', 
  @join_unique_key = 1, 
  @filter_type = 1, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;
GO

權限

只有系統管理員固定伺服器角色或db_owner固定資料庫角色的成員才能執行 sp_mergearticlecolumn