Specifying a where clause with the create article command

You can include one or more where clauses in an article. A where clause sets criteria for the column or parameter values that are to be replicated. If you omit the where clause, Replication Server copies all rows for columns specified in the table replication definition or all parameters specified in the function replication definition.

The where clause syntax for articles is:

[where (column_name | @param_name) 
      {< | > >= | <= | = | &} value
    [and {column_name | @param_name}
      {< | > >= | <= | = | &} value]...]
    [or where (column_name | @param_name) 
      {< | > >= | <= | = | &} value
    [and {column_name | @param_name}
      {< | > >= | <= | = | &} value]...]
...

Each column name in a where clause must be listed in the searchable columns list of the table replication definition. The value for each column must have the same datatype as the column to which it is compared.

NoteEach where clause in a article is joined by the or operator. However, the !=, !<, !>, and or operators are not supported inside a where clause. The & operator is supported only on rs_address columns. For details on using the rs_address datatype, see “Using the rs_address datatype” and “Bitmap subscriptions”.

The following example creates an article named titles_art for the publication named pubs2_pub, using a where clause that limits replication to rows where the value in the type column is ‘popular_comp.’

create article titles_art
    for pubs2_pub with primary at TOKYO_DS.pubs2
    with replication definition titles_rep
    where type = 'popular_comp'

Refer to Chapter 3, “Replication Server Commands,” in the Replication Server Reference Manual for complete syntax and usage guidelines.