Use the create function command to register a replicated stored procedure with Replication Server. When a stored procedure is executed, Replication Server maps it to a replication definition. The replication definition contains a user-defined function name that matches the name of the stored procedure.
Replication Server delivers the function to the Replication Server that is primary for the replication definition. When the destination Replication Server that owns the replication definition receives the function, it maps the stored procedure parameters into the commands for the user-defined function.
The syntax for the create function command is:
create function replication_definition.function ([@parameter datatype [, @parameter datatype]...])
The replication_definition must be an existing replication definition.
Observe these guidelines when using this command:
Execute this command at the Replication Server where the replication definition was created.
Do not use the names of system functions. See Chapter 2, “Customizing Database Operations” for the list of reserved system-function names.
Include the parentheses surrounding the listed parameters, even when you are defining functions with no parameters.
If you are not using a function-string class for which default generated function strings are provided, after you have created a user-defined function, use the create function string command to add a function string. See Chapter 2, “Customizing Database Operations” for details.
The following example creates a user-defined function named Stock_receipt. The function is associated with the Items_rd replication definition:
create function Items_rd.Stock_receipt (@Location int, @Recpt_num int, @Item_no char(15), @Qty_recd int)
When a user executes the replicated stored procedure, Replication Server now delivers it.