Built-in functions in SQL

A function can be defined as a set of instructions that performs a certain task automatically, and can be called within SQL instructions. Broadly, we can classify two large groups or categories of functions:

  • Built-in functions: These are the system’s own functions, already defined by SQL Server.

  • User-defined functions: These are functions created by the user to define their own personalized functionality. You can take a look at: User functions

In this section, we will focus on explaining those most used built-in functions when working with SQL Server. For more information, access the Microsoft documentation.

There are different types of built-in functions:

  • Aggregate functions: allow you to perform operations on a set of results, returning a single aggregate value. For more information, go to the section on Aggregate functions and GROUP BY.

  • Analytical functions: calculate an aggregate value based on a group of rows.

  • Bit Manipulation Features: process and store data more efficiently than individual bits.

  • Category functions: return a category value for each row of a partition.

  • Rowset functions: return objects that can be used as table references in SQL statements.

  • Scalar functions: Operate on a single value and then return a single value. For more information, go to the section on scalar functions.