Creating, Altering, and Removing User-Defined Functions
The UserDefinedFunction object provides functionality that lets users programmatically manage user-defined functions in Microsoft SQL Server. User-defined functions support input and output parameters, and also support direct references to table columns.
SQL Server requires assemblies to be registered within a database before these can be used inside stored procedures, user defined functions, triggers, and user defined data types. SMO supports this feature with the SqlAssembly object.
When the UserDefinedFunction object references a .NET assembly, you must register the assembly by creating a SqlAssembly object and adding it to the SqlAssemblyCollection object, which belongs to the Database object.