SQL Server Interview Question #112

What is a user-defined function (UDF) in SQL Server?

Views, Stored Procedures & User-Defined Functions Mid-Level Intermediate

Detailed Explanation

A user-defined function is a reusable database function created by developers. It accepts parameters and returns either a scalar value or a table.

Major categories include scalar UDFs, inline table-valued functions, and multi-statement table-valued functions. SQL Server places restrictions on side effects inside functions; they are intended primarily for computations and reusable query expressions rather than arbitrary database modifications.