sp_articlecolumn (Transact-SQL)

用來指定發行項所包括的資料行,以垂直篩選已發行之資料表的資料。這個預存程序執行於發行集資料庫的發行者端。

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

語法

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

引數

  • [@publication=] 'publication'
    這是發行項所在的發行集名稱。publication 是 sysname,沒有預設值。

  • [@article=] 'article'
    這是發行項的名稱。article 是 sysname,沒有預設值。

  • [@column=] 'column'
    這是要加入或卸除之資料行的名稱。column 是 sysname,預設值是 NULL。如果是 NULL,就會發行所有資料行。

  • [@operation =] '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= ] 'publisher'
    指定非 Microsoft 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

權限

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