How to: Include User-Defined Functions in Queries

You can include a user-defined function in queries of Microsoft SQL Server databases. You can include any of the three types of functions:

  • Non-updatable functions returning a table.

  • Updatable functions returning a table.

  • Functions returning a scalar.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To include an updatable or non-updatable table function in a query or view

  1. Design the query to which you want to add the function. In the Query and View Designer, be sure the Diagram pane is visible.

  2. In Server Explorer, expand the Data Connections node and the particular node for the database you are working on.

  3. Expand the Functions node.

  4. From the list of functions, drag the function onto the Diagram pane.

To include a scalar function in a query or view

  1. Design the query to which you want to add the function. In the Query and View Designer, be sure the Criteria pane is visible.

  2. In Server Explorer, expand the Data Connections node and the particular node for the database you are working on.

  3. Expand the Functions node.

  4. In the first blank row of the Criteria pane, enter the name of the function in the Column column.

See Also

Other Resources

Working with Stored Procedures and User-Defined Functions

Designing Queries and Views