SqlExpression CHAR LENGTH
From Eigenpedia
Contents |
Syntax
CHAR_LENGTH( string ) CHARACTER_LENGTH( string )
Purpose
Returns the number of characters within a string.
Input
- string [VARCHAR] - string to get character length of
Output
- [INTEGER] - number of characters in the string.
- if string is null, returns null
- if string is empty string, returns 0
Example
| Function | Result |
|---|---|
| CHAR_LENGTH( cast('this' as varchar(10)) ) | 4 |
| CHAR_LENGTH( cast(null as varchar(2)) ) | null |
| CHARACTER_LENGTH( 'abcdefg1234 34 ' ) | 16 |
| CHARACTER_LENGTH( cast('this' as char(15)) ) | 15 |

