Compartir a través de


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

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

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