SQL Built-In functions | SQL Tutorial and Query Example

Text copied!

SQL Built-In functions


  • Types of SQL functions :

    1. User-defined function

    1. User-defined function :

    A user-defined function is a custom function created by a user. SQL Server allows you to create your own functions using the 'CREATE FUNCTION' statement that enables you to perform specific calculations.

    2. System-defined function :

    SQL Server provides extensive collection of built-in system functions is available that perform various tasks related to the database system. It is also famous as 'built-in functions'.

    Calling function :

    Calling function simply means executing or running it. To call a function in SQL Server, you can use the 'SELECT' statement in a SQL query.

    SQL Built-In functions
    Here's a list of popular SQL built-in functions :

    1. String functions :

    Here's an example of SQL built-in function :

    [i] Let's assume you have a table called [Employees] table.

    To enhance your understanding of 'SQL functions', be sure to check out our next tutorial.
    SELECT schema_name.function_name( arguments );
            
    • CHARINDEX( )
    • CONCAT( )
    • LEN( )
    • LOWER( )
    • UPPER( )
    • REPLACE( )
    • SUBSTRING( )
    • LEFT( )
    • RIGHT( )
    • TRIM( )
    • RTRIM( )
    • LTRIM( )
    • STUFF( )
    • PATINDEX( )
    • QUOTENAME( )
    • STR( )
    • REVERSE( )
    • CHAR( )
    • NCHAR( )
    • SPACE( )
            
    • ROUND( )
    • FLOOR( )
    • CEILING( )
            
    • GETDATE( )
    • DATEPART( )
    • DATEADD( )
    • DATEDIFF( )
    • FORMAT( )
            
    • SUM( )
    • COUNT( )
    • AVG( )
    • MIN( )
    • MAX( )
    • ROW_NUMBER( )
    • RANK( )
    • DENSE_RANK( )
    • LAG( )
    • LEAD( )
            
    • CAST( )
    • CONVERT( )
    • PARSE( )
    • TRY_CAST( )
    • TRY_CONVERT( )
    • TRY_PARSE( )
    • ISNULL( )
    • COALESCE( )
    • NULLIF( )
            
    • XML PATH( )
    • XML VALUE( )
    • XML EXIST( )
    • XML QUERY( )
    • XML MODIFY( )
            
    SQL Built-In functions
    SELECT MIN(Salary) AS MIN_SALARY, MAX(Salary) AS MAX_SALARY
    FROM [Employees];
            
    SQL Built-In functions

    Frequently Asked Questions :

    The five built-in functions in SQL include aggregate functions (e.g., SUM, AVG), string functions (e.g., CONCAT, LENGTH), numeric functions (e.g., ABS, ROUND), date functions (e.g., DATEADD, DATEDIFF), and conversion functions (e.g., CAST, CONVERT).
    Built-in functions of SQL Server include aggregate functions (e.g., SUM, AVG), string functions (e.g., CONCAT, LEN), numeric functions (e.g., ABS, ROUND), date functions (e.g., DATEADD, DATEDIFF), and system functions (e.g., @@ERROR, @@VERSION).
    Built-in SQL refers to functions and capabilities inherently available within the SQL language itself, without requiring additional programming or extensions.
    Yes, SQL does have built-in functionalities, including various functions for data manipulation, querying, and management operations.