更新日期: 2005 年 12 月 5 日
对合并发布进行垂直分区。此存储过程在发布服务器的发布数据库中执行。
语法
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'
 发布的名称。Publication 的数据类型是 sysname,无默认值。
- [ @article = ] 'article'
 发布中的项目的名称。article 的数据类型为 sysname,无默认值。
- [ @column =] 'column'
 标识要在其中创建垂直分区的列。column 的数据类型为 sysname,默认值为 NULL。如果为 NULL 和@operation = N'add',默认情况下,源表中的所有列将添加到项目。当 operation 设置为 drop 时,column 不能为 NULL。若要从项目中排除列,执行 sp_mergearticlecolumn,并为从指定的 article 中删除的每列指定 column 和@operation = N'drop'。
- [ @operation =] 'operation'
 复制状态。operation 的数据类型为 nvarchar(4),默认值为 ADD。add 对列进行复制标记。drop 清除该列。
- [ @schema_replication=] 'schema_replication' 
 指定当合并代理运行时将传播架构更改。schema_replication 的数据类型为 nvarchar(5),默认值为 FALSE。.gif) 注意: 注意:- 对于 schema_replication,只支持 FALSE。 
- [ @force_invalidate_snapshot = ] force_invalidate_snapshot 
 启用或禁用使快照失效的功能。force_invalidate_snapshot 的数据类型为 bit,默认值为 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
请参阅
参考
其他资源
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)
筛选已发布数据
帮助和信息
更改历史记录
| 发布日期 | 历史记录 | 
|---|---|
| 2005 年 12 月 5 日 | 
 | 
.gif)