SQLforGeeks
  • Home
  • SQL
  • SQL Tutorial
  • SQL Syntax
  • Our Services
Contact
  1. SQL
  2. LEN function

Text copied!

« Previous
Next »

LEN function

June 5, 2023, 7:08 p.m. under SQL

  • Hi! You should check CONCAT function post first.

    In SQL, LEN function is used to determine the length of the specified string.

    What is a String?

    In SQL, A string is a data type used to store data that can contain combination of numbers, letters, whitespaces and symbols. In simple term, String is a word or a sequence of characters.

    What is a Substring?

    A substring is a consecutive sequence of characters or a portion of a string.

    The syntax of the LEN function generally looks like this :
    LEN(string)
            

    • Specify the 'string' in single quotes ( ' ' ) or 'column' whose length you want to determine.

    Here's an example of how you might use the LEN function :

    1. Let's assume we have a table named "[Employees]".

    LEN function

    2. Let's assume you want to determine the length of each employees name from [Employees] table.

    3. Run below SQL statement :

    SELECT LEN(Employee_Name)
    FROM [Employees];
            

    4. In above statement, LEN function determines the length of each employee's name from the Employee_Name column.

    It returns 4 for employees 'Mike', 'John' and 'Alex' due to their total letter count of 4, While for the employees 'Dolly' and 'Casey' it returns 5 due to their total letter count of 5.

    LEN function
    Remember :

    Using this function in a select statement won't modify the [Employees] table directly, but it will only be reflected in the select statement's output.

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

    Frequently Asked Questions :

    What is LEN function in SQL?

    The LEN function in SQL returns the length of a string.

    How to check length in SQL?

    To check the length in SQL, you can use the LEN function.

    What is difference between length and Len in SQL?

    In SQL, LENGTH is used in some databases like MySQL, while LEN is used in others like SQL Server; both perform similar tasks.

    What is the LEN function in data?

    The LEN function in data calculates the length of a string or the number of characters in a field.
    Thank You! You should check REPLACE 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

    SQL Built-In functions

    CHARINDEX function

    DATEADD function

    CONCAT 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