Help Center > > User Guide> Microsoft SQL Server Database Management> Function Management> Creating a Function

Creating a Function

Updated at: Mar 20, 2020 GMT+08:00

Scenarios

Functions return the results of a specific action quickly. This section describes how to create a function.

To create functions, you need to obtain the CREATE ROUTINE permission. To alter and drop functions, you need the ALTER ROUTINE permission.

Prerequisites

You have obtained the login permission and logged in to the database management page.

Function Type

There are three types of functions supported in Microsoft SQL Server: inline table-valued function, multi-statement table-valued function, and scalar-valued function. This following uses the inline table-valued function as an example to describe how to create a function.

  • Table value functions can be inline table-valued functions or multi-statement table-valued functions. You can use the table-valued function templates to create functions.
  • Scalar-valued functions can be created by using a scalar-value function template.
  • System functions can only be viewed and cannot be edited.
  1. In the navigation tree on the left, right-click Functions under the target database and choose Create Function > Inline Table-valued Function from the shortcut menu.
  2. On the page for editing a function, click Set Template Parameter. In the displayed dialog box, set required parameters and click OK.
  3. Click Save.
  4. Click Execute. In the displayed dialog box, set required parameters and click Execute.
  5. View the result.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel