sp_mergearticlecolumn (Transact-SQL)

更新: 2005 年 12 月 5 日

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

主題連結圖示Transact-SQL 語法慣例

語法

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

引數

  • [ @publication =] 'publication'
    這是發行集的名稱。Publicationsysname,沒有預設值。
  • [ @article =] 'article'
    這是發行集中的發行項名稱。articlesysname,沒有預設值。
  • [ @column =] 'column'
    識別用來建立垂直資料分割的資料行。columnsysname,預設值是 NULL。如果是 NULL 和 @operation = N'add',依預設,會將來源資料表中所有的資料行加入至發行項。當 operation 設為 drop 時,column 不能是 NULL。若要排除發行項中的資料行,請執行 sp_mergearticlecolumn,指定要從指定 article 中移除的每個資料行的 column@operation = N'drop'
  • [ @operation =] 'operation'
    這是複寫狀態。operationnvarchar(4),預設值是 ADD。add 會標示複寫的資料行。drop 會清除資料行。
  • [ @schema_replication=] 'schema_replication'
    指定當執行合併代理程式時,將傳播結構描述變更。schema_replicationnvarchar(5),預設值是 FALSE。

    ms188063.note(zh-tw,SQL.90).gif附註:
    只支援 schema_replication 使用 FALSE
  • [ @force_invalidate_snapshot = ] force_invalidate_snapshot
    啟用或停用使快照集失效的能力。force_invalidate_snapshotbit,預設值是 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。如需詳細資訊,請參閱<合併式複寫如何偵測並解決衝突>的「追蹤層級」一節。

權限

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

範例

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.EmployeeID = 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

請參閱

參考

複寫預存程序 (Transact-SQL)

其他資源

How to: Define and Modify a Join Filter Between Merge Articles (Replication Transact-SQL Programming)
How to: Define and Modify a Parameterized Row Filter for a Merge Article (Replication Transact-SQL Programming)
篩選發行的資料

說明及資訊

取得 SQL Server 2005 協助

變更歷程記錄

版本 歷程記錄

2005 年 12 月 5 日

新增內容:
  • 記載對已發行資料表的資料行限制。