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