Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Removes specified characters from the start, end, or both ends of a string.
Syntax
trim([leading | trailing | both] [characters] from <string>)
Arguments
Required
<string>: The string to trim.
Optional
mode: Where to trim from (leading,trailing, orboth). Defaults toboth.characters: The characters to remove. Defaults to space.
Returns
Returns a text value with specified characters removed.
Considerations
- Removes individual characters from the set, not the string as a pattern.
- Default behavior removes spaces from both ends.
Examples
Trim Characters
Remove specified characters from both ends.
SELECT trim(both 'xyz' from 'yxTomxx') AS result;
Returns 'Tom', removing all x, y, and z characters from both ends.