共用方式為


How to: View and Modify Article Properties (Replication Transact-SQL Programming)

Articles can be modified and their properties returned programmatically using replication stored procedures. The stored procedures that you use depend on the type of publication to which the article belongs.

To view the properties of an article belonging to a snapshot or transactional publication

  1. Execute sp_helparticle, specifying the name of the publication for the @publication parameter and the name of the article for the @article parameter. If you do not specify @article, information will be returned for all articles in the publication.

  2. Execute sp_helparticlecolumns for table articles to list all columns available in the base table.

To modify the properties of an article belonging to a snapshot or transactional publication

  1. Execute sp_changearticle, specifying the article property being changed in the @property parameter and the new value of this property in the @value parameter.

    ms147928.note(zh-tw,SQL.90).gif附註:
    If the change requires the generation of a new snapshot, you must also specify a value of 1 for @force_invalidate_snapshot, and if the change requires that Subscribers be reinitialized, you must also specify a value of 1 for @force_reinit_subscription. For more information on the properties that, when changed, require a new snapshot or reinitialization, see 變更發行集與發行項屬性.

To view the properties of an article belonging to a merge publication

  1. Execute sp_helpmergearticle, specifying the name of the publication for the @publication parameter and the name of the article for the @article parameter. If you do not specify these parameters, information will be returned for all articles in a publication or at the publisher.

  2. Execute sp_helpmergearticlecolumn for table articles to list all columns available in the base table.

To modify the properties of an article belonging to a merge publication

  1. Execute sp_changemergearticle, specifying the article property being changed in the @property parameter and the new value of this property in the @value parameter.

    ms147928.note(zh-tw,SQL.90).gif附註:
    If the change requires the generation of a new snapshot, you must also specify a value of 1 for @force_invalidate_snapshot, and if the change requires that Subscribers be reinitialized, you must also specify a value of 1 for @force_reinit_subscription. For more information on the properties that, when changed, require a new snapshot or reinitialization, see 變更發行集與發行項屬性.

範例

This transactional replication example returns the properties of the published article.

DECLARE @publication AS sysname;
SET @publication = N'AdvWorksProductTran';

USE [AdventureWorks]
EXEC sp_helparticle
  @publication = @publication;
GO

This transactional replication example changes the schema options for the published article.

DECLARE @publication AS sysname;
DECLARE @article AS sysname;
DECLARE @option AS int;
SET @publication = N'AdvWorksProductTran';
SET @article = N'Product';
SET @option = (SELECT CAST(0x0000000002030073 AS int));

-- Change the schema options to replicate schema with XML.
USE [AdventureWorks]
EXEC sp_changearticle 
  @publication = @publication,
  @article = @article, 
  @property = N'schema_option', 
  @value = @option,
  @force_invalidate_snapshot = 1;
GO

This merge replication example returns the properties of the published article.

DECLARE @publication AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks]
EXEC sp_helpmergearticle
  @publication = @publication;
GO

This merge replication example changes the conflict detection settings for a published article.

DECLARE @publication AS sysname;
DECLARE @article AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @article = N'SalesOrderHeader';

-- Enable column-level conflict tracking.
-- Changing this property requires that existing subscriptions
-- be reinitialized and that a new snapshot be generated.
USE [AdventureWorks]
EXEC sp_changemergearticle 
  @publication = @publication,
  @article = @article, 
  @property = N'column_tracking', 
  @value = N'true',
  @force_invalidate_snapshot = 1,
  @force_reinit_subscription = 1;
GO

請參閱

工作

How to: View and Modify Article Properties (RMO Programming)

概念

Programming Replication Using System Stored Procedures

其他資源

變更發行集與發行項屬性
進階合併式複寫衝突偵測與解決

說明及資訊

取得 SQL Server 2005 協助