Skip to main content

LTRIM function

Removes leading (left-side) characters from a string.

Syntax

LTRIM(string [, characters])

Arguments

  • string: The string to trim.

  • characters: Optional. A string containing the set of characters to remove. Each character in this string is removed individually from the beginning, not as a substring. The default is a single space.

Returns

A VARCHAR with the specified leading characters removed.

Examples

-- Example 1: Remove leading spaces (single parameter)
> SELECT LTRIM('   SQL   ');
'SQL   '

-- Example 2: Remove set of characters
> SELECT LTRIM('acbabSQL   ', 'abc');
'SQL   '

-- Example 3: Characters are removed individually, not as substring
-- 'abc' means remove any 'a', 'b', or 'c' characters
> SELECT LTRIM('cbaHello', 'abc');
'Hello'

-- Example 4: No matching characters to remove
> SELECT LTRIM('Hello World', 'x');
'Hello World'

See Also