1.

What is User-defined function? What are its various types?

Answer»

The user-defined functions in SQL are like functions in any other PROGRAMMING language that accept parameters, perform complex calculations, and return a value. They are written to use the logic repetitively WHENEVER required. There are two types of SQL user-defined functions:

  • SCALAR Function: As explained earlier, user-defined scalar functions return a single scalar value.
  • Table-Valued Functions: User-defined table-valued functions return a table as output.
    • Inline: returns a table data type based on a single SELECT statement.
    • Multi-statement: returns a tabular result-set but, unlike inline, multiple SELECT STATEMENTS can be USED inside the function body.


Discussion

No Comment Found