Character functions

The following table describes the supported character functions.

Function Description
ascii Returns the ASCII code for the first character in a string.
char Returns the character corresponding to an integer code.
char_length Returns the number of characters in a string.
charindex Returns the starting position of one string within another.
compare Compares two strings based on alternate collation rules and returns a comparison integer.
difference Returns a value representing the difference between two soundex codes.
left Returns the leftmost characters of a string.
len Returns the string length excluding trailing spaces.
lower Converts all uppercase letters to lowercase.
ltrim Removes leading spaces from a string.
patindex Returns the starting position of a pattern in a string.
replicate Repeats a string a specified number of times.
reverse Returns a string with characters in reverse order.
right Returns the rightmost characters of a string.
rtrim Removes trailing spaces.
softkey Returns a key value for sorting based on collation rules.
soundex Returns a 4-character soundex code for strings to compare phonetic similarity.
space Returns a string consisting of a specified number of spaces.
str Converts a numeric value to a string and pads it to a specified length.
str_replace Replaces occurrences of a substring with another string.
stuff Deletes a specified number of characters from a string and inserts another string.
substring Extracts a substring from a string.
uhighsurr Returns 1 if the Unicode value at a position is the high half of a surrogate pair; otherwise, 0.
ulowsurr Returns 1 if the Unicode value at a position is the low half of a surrogate pair; otherwise, 0.
upper Converts all lowercase characters to uppercase.
uscalar Returns the Unicode scalar value of the first Unicode character in an expression.
valid_name Returns 0 if a string is not a valid ID; otherwise, non-zero.

For more information, see SAP ASE functions.