You can use applied functions to replicate only selected data to remote sites, thus reducing network traffic.
The primary site contains all records, but the replicate site is interested only in records related to the state of California (CA). Only a selection of publishers and titles records need to be replicated, based on the state column. However, only the publishers table contains a state column.
Adding a state column to the titles table adds redundancy to the system. A second, more efficient solution ties updates to master and detail tables through stored procedures and then replicates the stored procedures using applied functions. The logic to maintain selective subscription is contained in the stored procedures.
For example, if, at the primary site, a publisher’s state is changed from NY to CA, a record for that publisher must be inserted at the replicate site. Having replicate rows inserted or deleted as a result of updates that cause rows in a subscription to change is called subscription migration.
To ensure proper subscription migration, subscriptions are needed for a set of “upper-level” stored procedures that control the stored procedures that actually perform the updates. It is the invocation for the upper-level stored procedure that is replicated from the primary site to the replicate site.
To handle changes in the state column, the replicate site must subscribe to updates when either the new state or the old state is CA.
Perform these steps at the primary and the replicate sites to enable selective substitution at the replicate Replication Server.
Create stored procedures that insert records into the publishers and titles tables and an upper-level stored procedure that controls the execution of both insert procedures.
Create stored procedures that delete records from the publishers and titles tables and an upper-level stored procedure that controls the execution of both delete procedures.
Create stored procedures that update records in the publishers and titles tables and an upper-level stored procedure that controls the execution of both update procedures.
Grant appropriate permissions on all upper-level stored procedures.