SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. SQL Built-In functions

Text copied!

« Previous
Next »

SQL Built-In functions

May 29, 2023, 5:46 p.m. under SQL

  • Hi! You should check SQL functions post first.

    In SQL, Function can be defined as a block/set of code that is used to perform a specific task or accomplish a particular purpose.

    It can be reused through multiple projects which reduces code redundancy. 'Code redundancy' refers to the practice of writing the same code multiple times within a project.

    Types of SQL functions :

    1. User-defined function

    2. System-defined function

    SQL Built-In functions
    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.

    Here's the syntax :

    SELECT schema_name.function_name( arguments );
            

    • Specify the schema name and function name after the 'SELECT' statement.

    • Specify the argument in 'parenthesis ( )'. An argument is a value that is passed into a function.

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

    1. String functions :

    • CHARINDEX( )
    • CONCAT( )
    • LEN( )
    • LOWER( )
    • UPPER( )
    • REPLACE( )
    • SUBSTRING( )
    • LEFT( )
    • RIGHT( )
    • TRIM( )
    • RTRIM( )
    • LTRIM( )
    • STUFF( )
    • PATINDEX( )
    • QUOTENAME( )
    • STR( )
    • REVERSE( )
    • CHAR( )
    • NCHAR( )
    • SPACE( )
            

    2. Numeric functions :

    • ROUND( )
    • FLOOR( )
    • CEILING( )
            

    3. Date and Time functions :

    • GETDATE( )
    • DATEPART( )
    • DATEADD( )
    • DATEDIFF( )
    • FORMAT( )
            

    4. Aggregate/Window functions :

    • SUM( )
    • COUNT( )
    • AVG( )
    • MIN( )
    • MAX( )
    • ROW_NUMBER( )
    • RANK( )
    • DENSE_RANK( )
    • LAG( )
    • LEAD( )
            

    5. Conversion functions :

    • CAST( )
    • CONVERT( )
    • PARSE( )
    • TRY_CAST( )
    • TRY_CONVERT( )
    • TRY_PARSE( )
    • ISNULL( )
    • COALESCE( )
    • NULLIF( )
            

    6. XML functions :

    • XML PATH( )
    • XML VALUE( )
    • XML EXIST( )
    • XML QUERY( )
    • XML MODIFY( )
            
    Here's an example of SQL built-in function :

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

    SQL Built-In functions

    [ii] Let's assume you want to retrieve employee data from [Employees] table in order to identify the employees with the minimum and maximum salaries.

    [iii] Run below SQL statement :

    SELECT MIN(Salary) AS MIN_SALARY, MAX(Salary) AS MAX_SALARY
    FROM [Employees];
            

    [iv] Above statement uses 'MIN( )' and 'MAX( )' functions to retrieve the minimum and maximum salaries of employee's from [Employees] table.

    SQL Built-In functions

    [v] That's it! You have demonstrated the use of SQL 'built-in function'.

    To enhance your understanding of 'SQL functions', be sure to check out our next tutorial.

    Frequently Asked Questions :

    What are the 5 built-in functions in SQL?

    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).

    What are the builtin functions of SQL Server?

    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).

    What is built-in SQL?

    Built-in SQL refers to functions and capabilities inherently available within the SQL language itself, without requiring additional programming or extensions.

    Does SQL have built-in functionalities?

    Yes, SQL does have built-in functionalities, including various functions for data manipulation, querying, and management operations.
    Thank You! You should check CHARINDEX function post next.
    « Previous
    Next »
    RELATED :

    What is SQL

    What is T-SQL

    Difference between DBMS and Data Warehouse

    Download SQL Server

    Install SQL Server

    Download SQL Server Management Studio SSMS

    SQL Server Management Studio

    SQL Database

    Download database

    Restore database

    Backup database

    Attach database

    Detach database

    Create database

    Delete database

    Rename database

    Select database

    Database offline

    Database online

    SQL Commands

    SQL Tables

    Create table

    Truncate table

    Delete table

    Rename table

    Select table

    Alter table

    SQL Data Types

    SQL Comments

    SQL Constraints

    SQL Joins

    SQL inner join

    SQL left join

    SQL right join

    SQL full join

    SQL cross join

    SQL self join

    INSERT INTO SELECT statement

    INSERT INTO statement

    SQL Clauses

    SELECT clause

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    ORDER BY clause

    JOIN clause

    UNION clause

    UNION ALL clause

    TOP clause

    DISTINCT clause

    SQL Operators

    SQL Arithmetic operators

    SQL Comparison operators

    SQL Logical operators

    UNION operator

    UNION ALL operator

    INTERSECT operator

    EXCEPT operator

    LIKE operator

    NOT LIKE operator

    IN operator

    NOT IN operator

    IS NULL operator

    IS NOT NULL operator

    EXISTS operator

    NOT EXISTS operator

    BETWEEN operator

    NOT BETWEEN operator

    SQL Functions

    CHARINDEX function

    DATEADD function

    CONCAT function

    LEN function

    REPLACE function

    SUBSTRING function

    CASE statement

    GETDATE function

    DATEPART function

    DATEDIFF function

    CAST function

    TRY_CAST function

    CONVERT function

    TRY_CONVERT function

    ISNULL function

    NULLIF function

    COALESCE function

    SQL Window functions

    ROW_NUMBER function

    RANK function

    DENSE_RANK function

    IIF function

    CHOOSE function

    SQL Store Procedure

    Store Procedure vs. Function

    SQL Subquery

    SQL Aliases

    Temp table

    SQL Error Handling

    SQL Variables

    SQL Views

    SQL Merge

    SQL CTE

    SQL WITH TIES

    Define Transaction in DBMS

    ACID properties in DBMS

    Types of Triggers in DBMS


    • Have Some Questions?
    logo

    Elevate your data experience with SQL excellence

    Quick Links
    •  Home
    •  SQL Tutorial
    •  SQL Syntax
    •  Our Services
    Our Services
    • Web Development
    • BI Development
    • Data Warehousing
    • Data Integration ETL


    Follow Us

    GST Registered: XXAXXXXXXXZX
    Mumbai, Maharashtra, India support@sqlforgeeks.com

    © 2025 Copyright™ | All Rights Reserved | Privacy Policy