CREATE FUNCTION

Create a user-defined function.

Syntax
      CREATE [ OR ALTER ] FUNCTION [schema.] function
         ( [ { @parameter [ AS ][type_schema.] parameter_data_type  [ NULL ] [= default ] [ READONLY ] }
            [ ,...n ]
           ])
      RETURNS return_data_type
         [ WITH function_option [ , ...n ] ]
         [ AS ]
        BEGIN
           function_body
           RETURN scalar_expression
        END
    [ ; ]

Key:
    function            Name of the function(s) to add.
    schema              The schema to which the user-defined function belongs.
    parameter_data_type The data type of the function (not timestamp) 
                        CLR functions, accept a limited range of data types.

The details of the return clause will vary for Scalar, Inline/Multistatement Table-valued, or CLR functions.
See SQL Server books online or the resources on the SQL Links page.

“Form follows function” ~ Louis H. Sullivan.

Related commands

ALTER FUNCTION - Alter a user-defined function.
DROP FUNCTION - Remove a user-defined function.


 
Copyright © 1999-2026 SS64.com
Some rights reserved