アーティクルの定義

適用対象:SQL Server

このトピックでは、SQL Server Management Studio、Transact-SQL、またはレプリケーション管理オブジェクト (RMO)を使用して SQL Server でアーティクルを定義する方法について説明します。

このトピックの内容

始める前に

制限事項と制約事項

  • アーティクルの名前には % , * , [ , ] , | , : , " , ? を使用できません。 , ' , \ , / , < , >. データベース内のオブジェクトにこれらの文字が使用されているときに、そのオブジェクトをレプリケートする場合、そのオブジェクト名とは異なる名前をアーティクルに指定する必要があります。

セキュリティ

可能であれば、実行時、ユーザーに対してセキュリティ資格情報の入力を要求します。 資格情報を保存する必要がある場合は、Microsoft Windows .NET Framework に用意されている 暗号化サービス を使用します。

SQL Server Management Studio を使用する

パブリケーションの新規作成ウィザードにより、パブリケーションを作成し、アーティクルを定義します。 パブリケーションを作成したら、[パブリケーションのプロパティ - <パブリケーション]> ダイアログ ボックスでパブリケーションのプロパティを表示および変更します。 Oracle データベースからパブリケーションを作成する方法については、「Create a Publication from an Oracle Database」(Oracle データベースからパブリケーションを作成する) をご覧ください。

パブリケーションを作成し、アーティクルを定義するには

  1. Microsoft SQL Server Management Studio でパブリッシャーに接続し、サーバー ノードを展開します。

  2. [レプリケーション] フォルダーを展開し、 [ローカル パブリケーション] フォルダーを右クリックします。

  3. [新しいパブリケーション]をクリックします。

  4. パブリケーションの新規作成ウィザードのページに従い、以下の操作を実行します。

    • サーバーでディストリビューションが構成されていない場合は、ディストリビューターを指定します。 ディストリビューションの構成の詳細については、「Configure Publishing and Distribution」(パブリッシュとディストリビューションの構成) をご覧ください。

      [ディストリビューター] ページで、パブリッシャー サーバーが独自のディストリビューター (ローカル ディストリビューター) として機能するように指定した場合、このサーバーはディストリビューターとして構成されていないため、パブリケーションの新規作成ウィザードでサーバーを構成します。 [スナップショット フォルダー] ページで、ディストリビューターの既定のスナップショット フォルダーを指定します。 スナップショット フォルダーは、共有として指定したディレクトリです。このフォルダーの読み取りと書き込みをするエージェントには、このフォルダーへのアクセスを可能にする十分な権限が必要です。 フォルダーの適切なセキュリティ保護の詳細については、「Secure the Snapshot Folder」(スナップショット フォルダーのセキュリティ保護) をご覧ください。

      別のサーバーがディストリビューターとして機能するように指定する場合は、パブリッシャーからディストリビューターへの接続のため、 [管理パスワード] ページでパスワードを入力する必要があります。 このパスワードは、リモート ディストリビューターでパブリッシャーを有効にしたときに指定したパスワードと一致する必要があります。

      詳しくは、「 Configure Distribution」を参照してください。

    • パブリケーション データベースを選択します。

    • パブリケーションの種類を選択します。 詳細については、「Types of Replication」(レプリケーションの種類) をご覧ください。

    • パブリッシュするデータおよびデータベース オブジェクトを指定します。必要に応じて、テーブル アーティクルから列をフィルター選択し、アーティクルのプロパティを設定します。

    • 必要に応じて、テーブル アーティクルから行をフィルター選択します。 詳細については、「パブリッシュされたデータのフィルター選択」を参照してください。

    • スナップショット エージェントのスケジュールを設定します。

    • 以下のレプリケーション エージェントの実行および接続に使用される資格情報を指定します。

      - すべてのパブリケーション用スナップショット エージェント。

      - すべてのトランザクション パブリケーション用ログ リーダー エージェント。

      - 更新サブスクリプションを許可するトランザクション パブリケーション用キュー リーダー エージェント。

      詳細については、「 Replication Agent Security Model 」および「 Replication Security Best Practices」を参照してください。

    • 必要に応じて、パブリケーションのスクリプトを作成します。 詳細については、「レプリケーションのスクリプト作成」を参照してください。

    • パブリケーションの名前を指定します。

Transact-SQL の使用

パブリケーションが作成された後、プログラムでレプリケーション ストアド プロシージャを使用してアーティクルを作成できます。 アーティクルの作成に使用するストアド プロシージャは、定義するアーティクルのパブリケーションの種類によって決まります。 詳しくは、「 パブリケーションを作成」をご覧ください。

スナップショット パブリケーションまたはトランザクション パブリケーションのアーティクルを定義するには

  1. パブリッシャー側のパブリケーション データベースに対して、 sp_addarticleを実行します。 @publication にアーティクルが属しているパブリケーションの名前を、@article にアーティクル名を、@source_object にパブリッシュするデータベース オブジェクトを指定し、さらにその他のオプション パラメーターを指定します。 dbo 以外の場合は、@source_owner を使用してオブジェクトのスキーマ所有権を指定します。 アーティクルがログベースのテーブル アーティクルでない場合は、@type にアーティクルの種類を指定します。詳細については、「アーティクルの種類の指定(レプリケーション Transact-SQL プログラミング)」をご覧ください。

  2. テーブル内の行を行方向にフィルター選択する場合、またはアーティクルを表示する場合は、 sp_articlefilter を使用してフィルター句を定義します。 詳しくは、「 Define and Modify a Static Row Filter」をご覧ください。

  3. テーブル内の列を列方向にフィルター選択する場合、またはアーティクルを表示する場合は、 sp_articlecolumnを使用します。 詳しくは、「 Define and Modify a Column Filter」をご覧ください。

  4. アーティクルをフィルター選択する場合、 sp_articleview を実行します。

  5. パブリケーションに既存のサブスクリプションがあり、 immediate_sync 列の sp_helppublication0 を返す場合、 sp_addsubscription を呼び出して既存の各サブスクリプションにアーティクルを追加する必要があります。

  6. パブリケーションに既存のプル サブスクリプションがある場合、パブリッシャーで sp_refreshsubscriptions を実行し、既存のプル サブスクリプションに対して新しいアーティクルのみを含む新しいスナップショットを作成します。

    Note

    スナップショットを使用して初期化しないサブスクリプションの場合、この処理は sp_addarticle によって実行されるため、 sp_refreshsubscriptionsを実行する必要はありません。

マージ パブリケーションのアーティクルを定義するには

  1. パブリッシャー側のパブリケーション データベースに対して、 sp_addmergearticleを実行します。 @publication にパブリケーション名を、@article にアーティクルの名前を、@source_object にパブリッシュするオブジェクトを指定します。 テーブル行を行方向にフィルター選択する場合は、@subset_filterclause の値を指定します。 詳細については、「 マージ アーティクルのパラメーター化された行フィルターの定義および変更 」および「 静的行フィルターの定義および変更」を参照してください。 このアーティクルがテーブル アーティクルでない場合、@type にアーティクルの種類を指定します。 詳細については、「Specify Article Types (Replication Transact-SQL Programming)」(アーティクルの種類の指定 (レプリケーション Transact-SQL プログラミング)) をご覧ください。

  2. (省略可) パブリッシャー側のパブリケーション データベースに対して sp_addmergefilter を実行し、2 つのアーティクル間に結合フィルターを定義します。 詳しくは、「 マージ アーティクル間の結合フィルターの定義および変更」をご覧ください。

  3. (省略可) パブリッシャー側のパブリケーション データベースに対して sp_mergearticlecolumn を実行し、テーブル列をフィルター選択します。 詳しくは、「 Define and Modify a Column Filter」をご覧ください。

例 (Transact-SQL)

この例では、 Product テーブルに基づいてトランザクション パブリケーションにアーティクルを定義します。アーティクルは行方向および列方向にフィルター選択されます。

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

この例では、マージ パブリケーションのアーティクルを定義します。 SalesOrderHeader アーティクルは SalesPersonIDに基づいて静的にフィルター選択され、 SalesOrderDetail アーティクルは SalesOrderHeaderに基づいて結合フィルターが適用されます。

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.BusinessEntityID = 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

レプリケーション管理オブジェクト (RMO) の使用

レプリケーション管理オブジェクト (RMO) を使用することで、プログラムによってアーティクルを定義できます。 アーティクルの定義に使用する RMO クラスは、アーティクルを定義するパブリケーションの種類によって決まります。

例 (RMO)

次の例では、行フィルターと列フィルターを含むアーティクルをトランザクション パブリケーションに追加します。

// Define the Publisher, publication, and article names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2022";
string articleName = "Product";
string schemaOwner = "Production";

TransArticle article;

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

// Create a filtered transactional articles in the following steps:
// 1) Create the  article with a horizontal filter clause.
// 2) Add columns to or remove columns from the article.
try
{
    // Connect to the Publisher.
    conn.Connect();

    // Define a horizontally filtered, log-based table article.
    article = new TransArticle();
    article.ConnectionContext = conn;
    article.Name = articleName;
    article.DatabaseName = publicationDbName;
    article.SourceObjectName = articleName;
    article.SourceObjectOwner = schemaOwner;
    article.PublicationName = publicationName;
    article.Type = ArticleOptions.LogBased;
    article.FilterClause = "DiscontinuedDate IS NULL";

    // Ensure that we create the schema owner at the Subscriber.
    article.SchemaOption |= CreationScriptOptions.Schema;

    if (!article.IsExistingObject)
    {
        // Create the article.
        article.Create();
    }
    else
    {
        throw new ApplicationException(String.Format(
            "The article {0} already exists in publication {1}.",
            articleName, publicationName));
    }

    // Create an array of column names to remove from the article.
    String[] columns = new String[1];
    columns[0] = "DaysToManufacture";

    // Remove the column from the article.
    article.RemoveReplicatedColumns(columns);
}
catch (Exception ex)
{
    // Implement appropriate error handling here.
    throw new ApplicationException("The article could not be created.", ex);
}
finally
{
    conn.Disconnect();
}
' Define the Publisher, publication, and article names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2022"
Dim articleName As String = "Product"
Dim schemaOwner As String = "Production"

Dim article As TransArticle

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

' Create a filtered transactional articles in the following steps:
' 1) Create the  article with a horizontal filter clause.
' 2) Add columns to or remove columns from the article.
Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Define a horizontally filtered, log-based table article.
    article = New TransArticle()
    article.ConnectionContext = conn
    article.Name = articleName
    article.DatabaseName = publicationDbName
    article.SourceObjectName = articleName
    article.SourceObjectOwner = schemaOwner
    article.PublicationName = publicationName
    article.Type = ArticleOptions.LogBased
    article.FilterClause = "DiscontinuedDate IS NULL"

    ' Ensure that we create the schema owner at the Subscriber.
    article.SchemaOption = article.SchemaOption Or _
    CreationScriptOptions.Schema

    If Not article.IsExistingObject Then
        ' Create the article.
        article.Create()
    Else
        Throw New ApplicationException(String.Format( _
         "The article {0} already exists in publication {1}.", _
         articleName, publicationName))
    End If

    ' Create an array of column names to remove from the article.
    Dim columns() As String = New String(0) {}
    columns(0) = "DaysToManufacture"

    ' Remove the column from the article.
    article.RemoveReplicatedColumns(columns)
Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("The article could not be created.", ex)
Finally
    conn.Disconnect()
End Try

次の例では、マージ パブリケーションに 3 つのアーティクルを追加します。 このアーティクルには列フィルターがあり、2 つの結合フィルターを使用してパラメーター化された行フィルターを他のアーティクルに反映します。

// Define the Publisher and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2022";

// Specify article names.
string articleName1 = "Employee";
string articleName2 = "SalesOrderHeader";
string articleName3 = "SalesOrderDetail";

// Specify join filter information.
string filterName12 = "SalesOrderHeader_Employee";
string filterClause12 = "Employee.EmployeeID = " +
    "SalesOrderHeader.SalesPersonID";
string filterName23 = "SalesOrderDetail_SalesOrderHeader";
string filterClause23 = "SalesOrderHeader.SalesOrderID = " +
    "SalesOrderDetail.SalesOrderID";

string salesSchema = "Sales";
string hrSchema = "HumanResources";

MergeArticle article1 = new MergeArticle();
MergeArticle article2 = new MergeArticle();
MergeArticle article3 = new MergeArticle();
MergeJoinFilter filter12 = new MergeJoinFilter();
MergeJoinFilter filter23 = new MergeJoinFilter();

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

// Create three merge articles that are horizontally partitioned
// using a parameterized row filter on Employee.EmployeeID, which is 
// extended to the two other articles using join filters. 
try
{
    // Connect to the Publisher.
    conn.Connect();

    // Create each article. 
    // For clarity, each article is defined separately. 
    // In practice, iterative structures and arrays should 
    // be used to efficiently create multiple articles.

    // Set the required properties for the Employee article.
    article1.ConnectionContext = conn;
    article1.Name = articleName1;
    article1.DatabaseName = publicationDbName;
    article1.SourceObjectName = articleName1;
    article1.SourceObjectOwner = hrSchema;
    article1.PublicationName = publicationName;
    article1.Type = ArticleOptions.TableBased;

    // Define the parameterized filter clause based on Hostname.
    article1.FilterClause = "Employee.LoginID = HOST_NAME()";

    // Set the required properties for the SalesOrderHeader article.
    article2.ConnectionContext = conn;
    article2.Name = articleName2;
    article2.DatabaseName = publicationDbName;
    article2.SourceObjectName = articleName2;
    article2.SourceObjectOwner = salesSchema;
    article2.PublicationName = publicationName;
    article2.Type = ArticleOptions.TableBased;

    // Set the required properties for the SalesOrderDetail article.
    article3.ConnectionContext = conn;
    article3.Name = articleName3;
    article3.DatabaseName = publicationDbName;
    article3.SourceObjectName = articleName3;
    article3.SourceObjectOwner = salesSchema;
    article3.PublicationName = publicationName;
    article3.Type = ArticleOptions.TableBased;

    if (!article1.IsExistingObject) article1.Create();
    if (!article2.IsExistingObject) article2.Create();
    if (!article3.IsExistingObject) article3.Create();

    // Select published columns for SalesOrderHeader.
    // Create an array of column names to vertically filter out.
    // In this example, only one column is removed.
    String[] columns = new String[1];

    columns[0] = "CreditCardApprovalCode";

    // Remove the column.
    article2.RemoveReplicatedColumns(columns);

    // Define a merge filter clauses that filter 
    // SalesOrderHeader based on Employee and 
    // SalesOrderDetail based on SalesOrderHeader. 

    // Parent article.
    filter12.JoinArticleName = articleName1;
    // Child article.
    filter12.ArticleName = articleName2;
    filter12.FilterName = filterName12;
    filter12.JoinUniqueKey = true;
    filter12.FilterTypes = FilterTypes.JoinFilter;
    filter12.JoinFilterClause = filterClause12;

    // Add the join filter to the child article.
    article2.AddMergeJoinFilter(filter12);

    // Parent article.
    filter23.JoinArticleName = articleName2;
    // Child article.
    filter23.ArticleName = articleName3;
    filter23.FilterName = filterName23;
    filter23.JoinUniqueKey = true;
    filter23.FilterTypes = FilterTypes.JoinFilter;
    filter23.JoinFilterClause = filterClause23;

    // Add the join filter to the child article.
    article3.AddMergeJoinFilter(filter23);
}
catch (Exception ex)
{
    // Do error handling here and rollback the transaction.
    throw new ApplicationException(
        "The filtered articles could not be created", ex);
}
finally
{
    conn.Disconnect();
}
' Define the Publisher and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2022"

' Specify article names.
Dim articleName1 As String = "Employee"
Dim articleName2 As String = "SalesOrderHeader"
Dim articleName3 As String = "SalesOrderDetail"

' Specify join filter information.
Dim filterName12 As String = "SalesOrderHeader_Employee"
Dim filterClause12 As String = "Employee.EmployeeID = " + _
    "SalesOrderHeader.SalesPersonID"
Dim filterName23 As String = "SalesOrderDetail_SalesOrderHeader"
Dim filterClause23 As String = "SalesOrderHeader.SalesOrderID = " + _
    "SalesOrderDetail.SalesOrderID"

Dim salesSchema As String = "Sales"
Dim hrSchema As String = "HumanResources"

Dim article1 As MergeArticle = New MergeArticle()
Dim article2 As MergeArticle = New MergeArticle()
Dim article3 As MergeArticle = New MergeArticle()
Dim filter12 As MergeJoinFilter = New MergeJoinFilter()
Dim filter23 As MergeJoinFilter = New MergeJoinFilter()

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

' Create three merge articles that are horizontally partitioned
' using a parameterized row filter on Employee.EmployeeID, which is 
' extended to the two other articles using join filters. 
Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Create each article. 
    ' For clarity, each article is defined separately. 
    ' In practice, iterative structures and arrays should 
    ' be used to efficiently create multiple articles.

    ' Set the required properties for the Employee article.
    article1.ConnectionContext = conn
    article1.Name = articleName1
    article1.DatabaseName = publicationDbName
    article1.SourceObjectName = articleName1
    article1.SourceObjectOwner = hrSchema
    article1.PublicationName = publicationName
    article1.Type = ArticleOptions.TableBased

    ' Define the parameterized filter clause based on Hostname.
    article1.FilterClause = "Employee.LoginID = HOST_NAME()"

    ' Set the required properties for the SalesOrderHeader article.
    article2.ConnectionContext = conn
    article2.Name = articleName2
    article2.DatabaseName = publicationDbName
    article2.SourceObjectName = articleName2
    article2.SourceObjectOwner = salesSchema
    article2.PublicationName = publicationName
    article2.Type = ArticleOptions.TableBased

    ' Set the required properties for the SalesOrderDetail article.
    article3.ConnectionContext = conn
    article3.Name = articleName3
    article3.DatabaseName = publicationDbName
    article3.SourceObjectName = articleName3
    article3.SourceObjectOwner = salesSchema
    article3.PublicationName = publicationName
    article3.Type = ArticleOptions.TableBased

    ' Create the articles, if they do not already exist.
    If article1.IsExistingObject = False Then
        article1.Create()
    End If
    If article2.IsExistingObject = False Then
        article2.Create()
    End If
    If article3.IsExistingObject = False Then
        article3.Create()
    End If

    ' Select published columns for SalesOrderHeader.
    ' Create an array of column names to vertically filter out.
    ' In this example, only one column is removed.
    Dim columns() As String = New String(0) {}

    columns(0) = "CreditCardApprovalCode"

    ' Remove the column.
    article2.RemoveReplicatedColumns(columns)

    ' Define a merge filter clauses that filter 
    ' SalesOrderHeader based on Employee and 
    ' SalesOrderDetail based on SalesOrderHeader. 

    ' Parent article.
    filter12.JoinArticleName = articleName1
    ' Child article.
    filter12.ArticleName = articleName2
    filter12.FilterName = filterName12
    filter12.JoinUniqueKey = True
    filter12.FilterTypes = FilterTypes.JoinFilter
    filter12.JoinFilterClause = filterClause12

    ' Add the join filter to the child article.
    article2.AddMergeJoinFilter(filter12)

    ' Parent article.
    filter23.JoinArticleName = articleName2
    ' Child article.
    filter23.ArticleName = articleName3
    filter23.FilterName = filterName23
    filter23.JoinUniqueKey = True
    filter23.FilterTypes = FilterTypes.JoinFilter
    filter23.JoinFilterClause = filterClause23

    ' Add the join filter to the child article.
    article3.AddMergeJoinFilter(filter23)

Catch ex As Exception
    ' Do error handling here and rollback the transaction.
    Throw New ApplicationException( _
        "The filtered articles could not be created", ex)
Finally
    conn.Disconnect()
End Try

参照

パブリケーションを作成する
Replication System Stored Procedures Concepts
既存のパブリケーションでのアーティクルの追加および削除
パブリッシュされたデータのフィルター選択
データとデータベース オブジェクトのパブリッシュ
Replication System Stored Procedures Concepts