Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
Alex Torin: "Several months ago I downloaded the trial versions of several Microsoft SQL administration tools that I was able to find using google. I had considerable trouble with most of them crashing... but using your product I was able to isolate and solve the problems I was having. I decided to add it to my toolkit and have recommended it to a few others".
DavidNR: "MS SQL Maestro is a great app. Loved it. I only used it for its blob support thus far, very nice and very fast".

More

Add your opinion

MS SQL Maestro online Help

Prev Return to chapter overview Next

Create UDF Wizard

Create UDF Wizard guides you through the process of creating a new UDF. See How To create UDF for instructions on running this wizard.
 

The basic principles of Create Object Wizards in MS SQL Maestro are explained in a separate topic. Below you will find a description of wizard steps that are unique for the current object.

 

Specify the properties for the new UDF according to your needs. The detailed description is given below.
 

 

Specifying UDF properties

Name

Specify a name for the function.

 

Owner

Select the owner of the UDF from the drop-down list. By default, only the owner of an object can perform various operations with the object. In order to allow other users to operate it, privileges must be granted. (However, users that have the superuser attribute can always access any object.)

 

Comment

Supply a comment to the UDF if necessary.

Defines the data type of the function result.

 

Language

The field stores the name of the language the function is implemented in. Select either of the available languages: SQL, C, internal, or the name of a u        ser-defined procedural language. For backward compatibility, the name may be enclosed by single quotes.

 

Check the Strict option to indicate that the function always returns NULL whenever any of its arguments are null. If this option is specified, the function is not executed when there are null arguments; a null result is assumed automatically instead. Uncheck the Strict option to indicate that the function will be called normally when some of its arguments are null. It is then the function author's responsibility to check for null values if necessary and to respond in the appropriate way.

 

Execution Privileges

Select Invoker to indicate that the function is to be executed with the privileges of the user that calls it (the default value).

Select Definer to specify that the function is to be executed with the privileges of the user that created it.

 

Stability

Set the attribute to inform the system whether it is safe to replace multiple evaluations of the function with a single evaluation, for run-time optimization. If none of these appear, Volatile is the default assumption.

Immutable indicates that the function always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its argument list. If this option is given, any call of the function with all-constant arguments can be immediately replaced with the function value.

Stable indicates that within a single table scan the function will consistently return the same result for the same argument values, but that its result could change across SQL statements. This is the appropriate selection for the functions in which the results depend on database lookups, parameter variables (such as the current time zone), etc. Also note that the current_timestamp family of functions qualify as stable, since their values do not change within a transaction.

Volatile indicates that the function value can change even within a single table scan, so no optimizations can be made. Relatively few database functions are volatile in this sense; some examples are random(), currval(), timeofday(). Note that any function that has side-effects must be classified volatile (even if its result is quite predictable) to prevent calls from being optimized away; an example is setval().

 

Note: You can also add the function definition within the Properties tab of Function Editor.

 

Execute As

Specify the security context under which the UDF is to be executed (For details see Execute As Clause (Microsoft SQL 2005 References)).

 

 

Schema Binding

Check the option to indicate that the UDF is bound to the database objects it references.

 

Function Type

Define Scalar, Inline Table-valued or Multi-statement Table-valued function type for the UDF.

 

Return Data Type

The return value of a scalar user-defined function is to be specified here. For Transact-SQL functions, all data types (including CLR user-defined types) are allowed except for the timestamp data type. For CLR UDFs, all data types (including CLR user-defined types) are allowed except for the text, ntext, image and timestamp data types. The nonscalar cursor and table types cannot be specified as a return data type in Transact-SQL or CLR UDFs.

 

Managing parameters of a new UDF

Use popup menu Add New Parameter... item to add a new parameter and set its properties in Parameter Editor. Use the Edit and Delete items to manage UDF parameters.

 

Specifying Function Definition

At this step you can specify the SQL definition for the new function. The step is optional: you can do it later using a non-modal editor.



Prev Return to chapter overview Next