Posted in Development

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

Author:

I am Kapil Singh Kumawat working on SQL Server since last 5 years. I am from Jaipur, Rajasthan, India and currently working in Cognizant Technology Solutions as SQL Server Developer. I have a good experience in writing queries, performance tuning, SSIS, SSAS, Power BI, Data migration and database designing. Apart from database I have interest in travelling,watching football and listening music. My blogs are also published on http://www.sqlservercentral.com/blogs/kapil-blogs/

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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