SQL functions

This section will be dedicated to the use of functions. We will see what the most important built-in functions of SQL Server are and how to use them, as well as declare, execute and manipulate our own user functions: both scalar functions and table functions

5 lessons

  1. Built-in functions in SQL

    A function can be defined as a set of instructions that performs a certain task automatically. Built-in functions are those system-specific functions, already defined by SQL-Server

  2. Built-in scalar functions in SQL

    Scalar functions operate on one value and return another. There are different types of scalar functions.

  3. User-defined Functions in SQL

    A function can be defined as a set of instructions that performs a certain task automatically. User-defined functions are those for defining your own custom functionality

  4. Scalar functions in SQL

    Scalar functions return a single scalar value whose data type will be defined in the RETURN clause

  5. Table functions in SQL

    Table functions return a result set in the form of a table. We will review the statements to create, execute, modify and eliminate user functions with examples

What you will learn in this section

A function takes values and returns a result. SQL Server ships with hundreds of them and also lets you write your own.

  1. Built-in functions: which families exist and what each one is for.
  2. Built-in scalar functions: text, dates, numbers and type conversion, with examples of each.
  3. User-defined functions: why and when to create your own.
  4. Scalar functions: your own functions that return a single value.
  5. Table-valued functions: your own functions that return a table and can be used in FROM as if they were one.

If you have not yet covered variables and BEGIN...END, it is worth reviewing them before writing your own functions.