What is User Defined function in SQL Server?

  • 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s