Previous Topic: Define SQL Server 2005 Files

Next Topic: Define a Table in SQL Server 2005

Define SQL Server 2005 Functions

Use the SQL Server Function Editor to define a function for a model or table in a SQL Server 2005 physical model.

To define a SQL Server 2005 function

  1. Click Functions on the Model menu.

    The SQL Server Function Editor opens.

  2. Select the function in the Navigation Grid that you want to define and work with the following options:

    Note: Click New New icon in property editors to create a new object on the toolbar to create a new function. Use the Enter filter text box to filter a very large list of functions to quickly locate the one that you want to define.

    Name

    Specifies the name of the function. Change the name of the function in this field.

    Schema

    Specifies the schema of the database to which the function belongs. Select the schema from the drop-down list.

    Type

    Specifies whether the function type is model-level or table-level. Select the type from the drop-down list.

    Attach To New

    Specifies to attach the selected function to each new table that you create. Clear the check box if you want to manually attach the function to new tables.

    Generate

    Generates SQL during forward engineering. Clear the check box if you do not want to generate SQL.

    Generate As Pre-Script

    Specifies whether the function is generated as part of a pre-script. Select an option from the drop-down list.

  3. Click the General tab and work with the following options:
    'Function_Name' Function Type

    Specifies the type of function and its associated values. Select one of the following function types from the drop-down list:

    Scalar Function

    Specifies the scalar function type, which returns a single data value. When you select Scalar Function, you can use the Null Input, Return Data Type, Encryption, and Schema Binding options that populate the grid to further define the function.

    Inline Table Function

    Specifies the inline table-valued function type, which returns a result set of single SELECT statement. When you select Inline Table Function, you can use the Null Input, Encryption, and Schema Binding options that populate the grid to further define the function.

    Multistatement Table Function

    Specifies the multi-statement table-valued function type, which returns a result set in table form, which was built from multiple statements. When you select Multistatement Table Function, you can use the Null Input, Encryption, Schema Binding, Return Table Definition, and Return Variable options that populate the grid to further define the function.

    Scalar Return Assembly Function

    Specifies the scalar return assembly function type, which returns a single value by executing a method from an assembly. When you select Scalar Return Assembly Function, you can use the Null Input, Return Data Type, Assembly, Class Name, and Method Name options that populate the grid to further define the function.

    Table Return Assembly Function

    Specifies the table return assembly function type, which returns a table of values by executing a method from an assembly. When you select Table Return Assembly Function, you can use the Null Input, Return Table Definition, Assembly, Class Name, and Method Name options that populate the grid to further define the function.

    Type

    Specifies the permission level in effect when the function is executed.

    Select User

    Specifies the user whose permissions are in effect for the execution of the function.

    Note: This option is only available if you have selected the Execute As User option in the Type drop-down list.

    'Function_Name' Parameter_Order_List

    Specifies the parameters for the function and lets you select the order in which the parameters execute and the properties of each one.

    Note: Click New New icon in property editors to create a new object on the toolbar to add a new parameter.

  4. Work with the other tabs in the editor to access additional design features, for example:
  5. (Optional) Click the Comment tab and enter any comments that you want to associate with the function.
  6. (Optional) Click the Where Used tab to view where the function is used within the model.
  7. (Optional) Click the UDP tab to work with user-defined properties for the function.
  8. (Optional) Click the Notes tab to view history information and view or edit user notes.
  9. Click Close.

    The function is defined and the SQL Server Function Editor closes.

More information:

Define the Code Type for an Object in a SQL Server Property Editor

View Expanded Code in a Property Editor

Change the Object Creation Order in a Property Editor

Define Permissions for an Object in a SQL Server Property Editor

Add a Comment in a Property Editor

Add a UDP in a SQL Server Physical Property Editor

SQL Server Browser for Functions, Script Templates, and Stored Procedures