December 8th, 2008

CHAR_LENGTH (no. of characters)

CHARACTER_LENGTH gives the number of characters in a character string (not the number of bytes)
and returns an integer.

Format:                         CHARACTER_LENGTH(string)

Example:           SELECT CUST_NAME,
                          CHARACTER_LENGTH(CUST_NAME) AS 'LENGTH'
                     FROM CUSTOMER_TBL;

Result:

                   

> The length of an empty string (‘ ‘) is zero.
> Access uses LEN(string) to find the number of characters.
> DB2 and Oracle use LENGTH(string) to find the number of characters.
> SQL Server uses DATALENGTH(string) to find the number of characters.
> MySQL uses BIT_COUNT(string) to find the number of bits.
> Oracle uses LENGTHB(string) to find the number of bits.
> CHARACTER_LENGTH and CHAR_LENGTH are synonymous.

Comments are closed.

Sorry, the comment form is closed at this time.