User Defined Functions



User Defined Functions in SQL Server


The User Defined Functions in SQL Server are like functions in any other programming language that accepts the parameters, performing complex calculations, and returning the result value.

A user defined function is a programmed routine that has its parameters set by the user of the system.

User defined functions often are seen as programming shortcuts as they define functions that perform specific tasks within a larger system, such as a database or spreadsheet program.


Syntax for User Defined Functions
CREATE FUNCTION Function_Name(@Parameter_Name Data_type, 
                                 .... @Parameter_Name Data_type
                             )
RETURNS Data_Type
AS
   BEGIN
      -- Function Body
      
      RETURN Data 
   END
Types of User Defined Functions

There are two types of UDF's.They are :

1. SCALAR FUNCTIONS : SQL scalar functions return a single value, based on the input value.

2. TABLE VALUED FUNCTIONS : A Table Valued User Defined Function accepts zero or more parameters and return a table variable. This type of function is special because it returns a table that you can query the results of a join with other tables.

A Table Valued function is further categorized into two types :

  • Inline table valued functions

  • Multi-statement table valued functions


    Connection String

    SQL Server Connection String Formats

    posted on 2019-08-27 05:53:53 - SQL Server Tutorials


    UNION

    union in SQL server

    posted on 2019-08-09 23:05:33 - SQL Server Tutorials


    System Functions

    System Functions in SQL Server

    posted on 2019-08-09 06:14:33 - SQL Server Tutorials


    Prompt Examples

    ChatGPT Prompt Examples

    posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


    Use Cases

    Chat GPT Key Use Cases

    posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


    Prompt Frameworks

    Prompt Frameworks

    posted on 2023-06-21 19:33:06 - ChatGPT Tutorials