SQL Functions Introduction
SQL Server provides built-in functions that help us perform calculations, manipulate data, work with dates, convert data types and handle NULL values.
What are SQL Functions?
SQL Functions are predefined operations provided by SQL Server that perform a specific task and return a value.
Types of SQL Functions
String Functions
String functions are used to manipulate and work with character and text data.
- LEN()
- UPPER()
- LOWER()
- SUBSTRING()
- REPLACE()
Numeric Functions
Numeric functions are used to perform mathematical calculations.
- ABS()
- CEILING()
- FLOOR()
- ROUND()
Date & Time Functions
Date and time functions are used to work with dates and times.
- GETDATE()
- DATEADD()
- DATEDIFF()
- YEAR()
- MONTH()
Conversion Functions
Conversion functions are used to convert data from one data type to another.
- CAST()
- CONVERT()
- TRY_CAST()
- TRY_CONVERT()
NULL Functions
NULL functions are used to handle NULL values in SQL Server.
- ISNULL()
- COALESCE()
- NULLIF()
Key Point
SQL Functions can be used inside SELECT statements to manipulate, calculate and transform data.