- User-defined functions encapsulate T-SQL statement and return a table or a scalar value to the caller.
- UDFs can not be executed using EXEC statement like stored procedure.
- UDFs cannot perform any DDL (Data Definition Language) like cannot CREATE, UPDATE tables, indexes or any permanent objects.
- UDFs can also accept parameters like stored procedures and used by variables inside the functions.
- There are two types of UDFs : Scalar valued function and Table valued function
- Scalar valued function returns a single value to the caller. While table valued function returns a table to the caller.
- When a table valued function contains a single line code then its called Inline table valued functions. While a table valued function containing multiple line T-SQL code its called Multistatement table valued function.