Creating a user-defined function

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:

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.