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'

包含本文的发布的名称。 @publicationsysname,无默认值。

[ @article = ] N'article'

项目的名称。 @articlesysname,无默认值。

[ @column = ] N'column'

要添加或删除的列的名称。 @column为 sysname,默认值为 NULL. 如果 NULL发布所有列。

[ @operation = ] N'operation'

指定在项目中添加还是删除列。 @operationnvarchar(5),默认值为 add.

  • add标记要副本 (replica)的列。
  • drop 取消标记列。

[ @refresh_synctran_procs = ] refresh_synctran_procs

指定是否重新生成支持立即更新订阅的存储过程以匹配复制的列数。 @refresh_synctran_procs为,默认值为 1. 如果 1,则重新生成存储过程。

[ @ignore_distributor = ] ignore_distributor

指示此存储过程是否执行而不连接到分发服务器。 @ignore_distributor,默认值为 0.

  • 如果0为数据库启用了发布,并且应刷新项目缓存以反映项目副本 (replica)的新列。
  • 如果 1允许为驻留在未发布的数据库中的项目删除项目列,则应仅在恢复情况下使用。

[ @change_active = ] change_active

允许修改具有订阅的发布中的列。 @change_active为 int,默认值为 0.

  • 如果未 0修改列。
  • 如果 1存在,则可以从具有订阅的活动项目添加或删除列。

[ @force_invalidate_snapshot = ] force_invalidate_快照

确认此存储过程执行的操作可能会使现有快照失效。 @force_invalidate_快照为,默认值为 0.

  • 0指定对项目所做的更改不会导致快照无效。 如果该存储过程检测到更改确实需要新的快照,则会发生错误,并且不进行任何更改。
  • 1指定对项目所做的更改可能会导致快照无效,如果存在需要新快照的现有订阅,则授予现有快照标记为已过时和生成的新快照的权限。

[ @force_reinit_subscription = ] force_reinit_subscription

确认此存储过程所执行的操作是否需要重新初始化现有订阅。 @force_reinit_subscription为,默认值为 0.

  • 0 指定对项目所做的更改不会导致重新初始化订阅。 如果该存储过程检测到更改将需要重新初始化订阅,则会发生错误,并且不进行任何更改。
  • 1 指定对项目所做的更改会导致现有订阅重新初始化,并授予订阅重新初始化的权限。

[ @publisher = ] N'publisher'

指定非 SQL Server 发布服务器。 @publisher为 sysname,默认值为 NULL.

@publisher 不应与 SQL Server 发布服务器一起使用。

[ @internal = ] internal

标识为仅供参考。 不支持。 不保证以后的兼容性。

返回代码值

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

注解

sp_articlecolumn用于快照 副本 (replica)和事务副本 (replica)。

只能使用 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