---
title: "What are all types of user defined functions?"  
description: "What are all types of user defined functions?"  
author: "Shrikant Mishra"  
published: 2019-05-06  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/23510/what-are-all-types-of-user-defined-functions  
category: "database"  
tags: ["database", "sql server"]  
reading_time: 1 minute  

---

# What are all types of user defined functions?

Three types of user defined **functions** are. :

- Scalar Functions.
- Inline Table valued functions.
- Multi statement valued functions.

```
Example :-CREATE FUNCTION dbo.udf_GetProductSales (       @Product VARCHAR(10),       @BeginDate DATETIME,       @EndDate DATETIME ) RETURNS MONEY AS BEGIN       DECLARE @Sales MONEY       SELECT @Sales = SUM(SalePrice)       FROM SalesHistory       WHERE             Product = @Product AND             SaleDate BETWEEN @BeginDate AND @EndDate       RETURN(@Sales) END
```

## Answers

### Answer by Shrikant Mishra

Three types of user defined **functions** are. :

- Scalar Functions.
- Inline Table valued functions.
- Multi statement valued functions.

```
Example :-CREATE FUNCTION dbo.udf_GetProductSales (       @Product VARCHAR(10),       @BeginDate DATETIME,       @EndDate DATETIME ) RETURNS MONEY AS BEGIN       DECLARE @Sales MONEY       SELECT @Sales = SUM(SalePrice)       FROM SalesHistory       WHERE             Product = @Product AND             SaleDate BETWEEN @BeginDate AND @EndDate       RETURN(@Sales) END
```


---

Original Source: https://www.mindstick.com/interview/23510/what-are-all-types-of-user-defined-functions

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
