Creates a user-defined function.
When you create a function replication definition, a user-defined function is automatically created. For more information, see create applied function replication definition and create request function replication definition.
If your application uses asynchronous procedure delivery associated with table replication definitions, you may need to create user-defined functions. For more information, see the Replication Server Administration Guide Volume 2.
create function replication_definition.function ([@param_name datatype [, @param_name datatype]...])
The name of the replication definition the function is for. You can create only one user-defined function for all the replication definitions for the same table. If there are multiple replication definitions for the same table, you can specify the name of any one of them. However, each replication definition has its own function string for the user-defined function.
The name of the function. The name must be unique for the replication definition and must conform to the rules for identifiers. The names of the system functions listed in Chapter 4, “Replication Server System Functions,”and all function names that begin with “rs_”, are reserved.
The name of an argument to the user-defined function. Each parameter name must be preceded by an @ sign and must conform to the rules for identifiers. The value of each parameter is supplied when the function is executed.
The datatype of the parameter. Some datatypes require a length, in parentheses, after the datatype name. See “Datatypes” for a description of the datatypes and their syntax. The datatype cannot be text, unitext, rawobject, or image.
Creates a user-defined function named newpublishers, with four parameters, for the publishers_rep replication definition:
create function publishers_rep.newpublishers (@pub_id char(4), @pub_name varchar(40), @city varchar(20), @state char(2))
Use create function to create user-defined functions.
Execute create function on the Replication Server where the replication definition was created.
User-defined functions may be used in asynchronous procedure delivery. See the Replication Server Administration Guide Volume 2 for more information about asynchronous procedures.
You must include the parentheses () surrounding the listed parameters, even when you are defining functions with no parameters.
For each of the three system-provided function-string classes in which the user-defined function will be used, and for each derived class that inherits from these classes, Replication Server generates a default function string for the user-defined function.
You can customize the function string in rs_sqlserver_function_class and in user-created function-string classes using create function string.
For each user-created base function-string class in which the user-defined function will be used, and for each derived class that inherits from such a class, you must create a function string, using create function string. The function string should invoke a stored procedure or RPC, with language appropriate for the replicate data server.
For an overview of function-string classes, function strings, and functions, see the Replication Server Administration Guide Volume 2.
Replication Server distributes the new user-defined function to qualifying sites through the replication system. The changes do not appear immediately at all such sites because of normal replication system lag time.
When you create a user-defined function for a replication definition, it is created for all replication definitions in the primary table.
create function requires “create object” permission.
create applied function replication definition, create function string, create request function replication definition, drop function