sp_articlecolumn (Transact-SQL)

適用於:SQL Server

用來指定發行項中包含的數據行,以垂直篩選已發佈數據表中的數據。 這個預存程式會在發行集資料庫的發行者端執行。

Transact-SQL 語法慣例

語法

sp_articlecolumn
    [ @publication = ] N'publication'
    , [ @article = ] N'article'
    [ , [ @column = ] N'column' ]
    [ , [ @operation = ] N'operation' ]
    [ , [ @refresh_synctran_procs = ] refresh_synctran_procs ]
    [ , [ @ignore_distributor = ] ignore_distributor ]
    [ , [ @change_active = ] change_active ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
    [ , [ @publisher = ] N'publisher' ]
    [ , [ @internal = ] internal ]
[ ; ]

引數

[ @publication = ] N'publication'

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

[ @article = ] N'article'

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

[ @column = ] N'column'

要加入或卸除之數據行的名稱。 @column為 sysname,預設值為 NULL。 如果 NULL為 ,則會發佈所有數據行。

[ @operation = ] N'operation'

指定是否要在發行項中加入或卸除數據行。 @operation為 nvarchar(5),預設值為 add

  • add 標記數據行以進行複寫。
  • drop 取消標記數據行。

[ @refresh_synctran_procs = ] refresh_synctran_procs

指定是否重新產生支援立即更新訂閱的預存程式,以符合復寫的數據行數目。 @refresh_synctran_procs為 bit,預設值為 1。 如果 1為 ,則會重新產生預存程式。

[ @ignore_distributor = ] ignore_distributor

指出這個預存程式是否執行而不連接到散發者。 @ignore_distributor為 bit,預設值為 0

  • 如果 0為 ,則必須啟用資料庫才能發行,而且應該重新整理發行項快取,以反映發行項所復寫的新數據行。
  • 如果 1為 ,則允許卸除位於未發佈資料庫中之發行項的發行項數據行;應該只在復原情況下使用。

[ @change_active = ] change_active

允許修改具有訂閱之發行集中的數據行。 @change_active為 int,預設值為 0

  • 如果 0為 ,則不會修改資料行。
  • 如果 1為 ,則可以從具有訂用帳戶的作用中發行項新增或卸除數據行。

[ @force_invalidate_snapshot = ] force_invalidate_snapshot

確認此預存程式所採取的動作可能會使現有的快照集失效。 @force_invalidate_snapshot為 bit,預設值為 0

  • 0 指定發行項的變更不會造成快照集無效。 如果預存程式偵測到變更確實需要新的快照集,就會發生錯誤,而且不會進行任何變更。
  • 1 會指定發行項的變更可能會導致快照集無效,而且如果有現有的訂用帳戶需要新的快照集,則提供現有快照集標示為過時和產生新快照集的許可權。

[ @force_reinit_subscription = ] force_reinit_subscription

確認此預存程式所採取的動作可能需要重新初始化現有的訂用帳戶。 @force_reinit_subscription為 bit,預設值為 0

  • 0 指定發行項的變更不會使訂閱重新初始化。 如果預存程式偵測到變更需要重新初始化訂閱,就會發生錯誤,而且不會進行任何變更。
  • 1 指定變更發行項會導致現有的訂閱重新初始化,並授與重新初始化訂閱的許可權。

[ @publisher = ] N'publisher'

指定非 SQL Server 發行者。 @publisher為 sysname,預設值為 NULL

@publisher不應該與 SQL Server 發行者搭配使用。

[ @internal = ] internal

僅供參考之用。 不支援。 我們無法保證未來的相容性。

傳回碼值

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

備註

sp_articlecolumn 用於快照式複寫和事務複製。

只有未訂閱的發行項可以使用 來篩選 sp_articlecolumn

範例

DECLARE @publication    AS sysname;
DECLARE @table AS sysname;
DECLARE @filterclause AS nvarchar(500);
DECLARE @filtername AS nvarchar(386);
DECLARE @schemaowner AS sysname;
SET @publication = N'AdvWorksProductTran'; 
SET @table = N'Product';
SET @filterclause = N'[DiscontinuedDate] IS NULL'; 
SET @filtername = N'filter_out_discontinued';
SET @schemaowner = N'Production';

-- Add a horizontally and vertically filtered article for the Product table.
-- Manually set @schema_option to ensure that the Production schema 
-- is generated at the Subscriber (0x8000000).
EXEC sp_addarticle 
    @publication = @publication, 
    @article = @table, 
    @source_object = @table,
    @source_owner = @schemaowner, 
    @schema_option = 0x80030F3,
    @vertical_partition = N'true', 
    @type = N'logbased',
    @filter_clause = @filterclause;

-- (Optional) Manually call the stored procedure to create the 
-- horizontal filtering stored procedure. Since the type is 
-- 'logbased', this stored procedures is executed automatically.
EXEC sp_articlefilter 
    @publication = @publication, 
    @article = @table, 
    @filter_clause = @filterclause, 
    @filter_name = @filtername;

-- Add all columns to the article.
EXEC sp_articlecolumn 
    @publication = @publication, 
    @article = @table;

-- Remove the DaysToManufacture column from the article
EXEC sp_articlecolumn 
    @publication = @publication, 
    @article = @table, 
    @column = N'DaysToManufacture', 
    @operation = N'drop';

-- (Optional) Manually call the stored procedure to create the 
-- vertical filtering view. Since the type is 'logbased', 
-- this stored procedures is executed automatically.
EXEC sp_articleview 
    @publication = @publication, 
    @article = @table,
    @filter_clause = @filterclause;
GO

權限

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