Use an applied function to distribute operations performed in a primary database to replicate databases. Applied functions allow you to realize important performance benefits. For example, if a client application must update a large number of row changes, you can create an applied function that changes many rows, rather than replicating the rows individually.
To use an applied function, you first create a stored procedure in the primary database and a corresponding stored procedure in the replicate database. Use sp_setrepproc command to mark the stored procedure to be replicated. At the primary Replication Server, you create an applied function replication definition for the stored procedure. Replicate Replication Servers can subscribe to the function replication definition. When the stored procedure in the primary database is invoked, the replicate Replication Server in turn executes the stored procedure in the subscribing replicate database.
Replication Server does not know in advance what data is needed by the stored procedure at the replicate databases until the execution of the stored procedure is subscribed, thus you must use bulk materialization or the no-materialization method when you subscribe to a function replication definition.
Replication Server executes the stored procedure in the replicate database as the maintenance user, which is consistent with normal data replication.
See “Implementing an applied function” for step-by-step instructions.