How to: |
The CHAR_LENGTH function returns the length of a character string. CHARACTER_LENGTH is identical to CHAR_LENGTH.
This function is most useful for columns described as VARCHAR (variable length character). For example, if a column described as GLOSS VARCHAR(10) contains
'bryllig' 'slythy ' 'toves '
then CHAR_LENGTH(GLOSS) would return
If the column is described as CHAR (non-variable length character), the same number is returned for all rows. In this case, CHAR_LENGTH(GLOSS) would return
To avoid counting trailing blanks use CHAR_LENGTH(TRIM (TRAILING FROM GLOSS)). See TRIM: Removing Leading or Trailing Characters (SQL) for details.
CHAR_LENGTH(arg)
where:
Character string
Is the value whose length is to be determined.
This function returns an integer value.
CHAR_LENGTH finds the length of the string. This example,
CHAR_LENGTH('abcdef')
returns 6.
This example,
CHAR_LENGTH('abcdef ')
returns 9, since trailing blanks are counted.
iWay Software |