What is SQL Functions and what are their different types?
Function:- Function in a database can be defined as the code segment consisting of a logical group of SQL statements which takes some input arguments (if required), run in a sequential order and returns the output either in the form of a single value or in the form of a table.
In SQL, Functions can be categorized into two categories:-
System defined function can again be further divided into further subsections which are given below:-
Aggregate function. Example: - Avg (), Min (), Max ()
Configuration function. Example:-@@servername (), @@version()
Cursor function. Example: -@@Fetch_status
Date and Time function. Example: - Getdate (), Month (), Day (), Year ()
Mathematical function. Example: - Floor (), Abs ()
Metadata function. Example: - DbName (), FileName ()
Other functions. Example: - cast (), convert ()
Rowset function. Example: - Openxml (), Openrowset ()
Security function. Example:-user(), UserId (), UserName ()
String function. Example: - Char (), Left (), Len ()
System Statistical function. Example:-@@connections
Text and Image function Example: - Textvalid ()
Types of UDF:-
Similarly, UDF can be divided Into 3 categories:-
Scalar UDF
Inline Table UDF
Multi statements UDF
Read More..   [368 clicks]
Published under: SQL Server Interview Questions · · · ·