Function

"Functions are nothing but a Database object that is being created for implementing or handling certain types of complex functionalities. "

In general, functions are sets of SQL statements that only accept input parameters (compared with Store Procedures), depending on which it simply takes some sort of inputs and displays a result accordingly, nothing more or less than that.

Functions | Pros

Some advantages of functions are:

      - Can be used with Clauses easily (like where, having and so on)
      - Function can be embedded in a Select statement
      - Easy to Use
      - Functionality Oriented

Function | Hierarchy

The complete hierarchy of a function is shown below in a reference chart, from the root to the base level:

Function | Type

Like a Stored Procedure, a Function is also categorized in the following two major categories:



System Defined Functions

System Defined Functions are those that are pre present in SQL Server for some base or important operations that will be hard to implement without System Defined Functions.

So System Defined Functions play an important role in dealing with some complex and rapidly required operations.

User Defined Functions

As it is clear from the name too, but still we can define User Defined Functions in most common words as:

"Functions, that user creates during implementing a query operation for making query easier and faster are called User Defined Functions."

Function | Creation

Here's sample function: