sql len()

SQL Functions

homeBack

Next

SQL LEN()

  • The LEN() Function

    The LEN() function is used to extract lenght from a text field.

    SQL LEN() Syntax

    SELECT LEN(column_name) FROM table_name

  • SQL LEN() Example

    Table Name ” emp”

    S.no Name1 Name2 City
    4857 Faran Khan Hyderabad
    2458 Peter Jhon Hyderabad
    8578 Sameer Ali Mumbai
    5874 Raj Kiran London

    Now we want to select the length of the values in the “City” column above.

    We use the following SELECT statement:

    SELECT LEN(City) as LengthOfCity FROM emp

    The result-set will look like this:

    LengthOfCity
    9
    9
    6
    6

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s