LTRIM Function

The LTRIM function removes specified leading pad characters from a string.
LTRIM Function

1  LTRIM ( source_string?  , pad_string )
Element Description Restrictions Syntax
pad_string Expression that specifies one or more characters to delete from source_string Must be a character expression Expression
source_string Expression that specifies a character string from which characters in pad_string are deleted Pad characters to the right of any character not in pad_string are not deleted Expression

The first argument to the LTRIM function must be a character expression from which to delete leading pad characters. The optional second argument is a character expression that evaluates to a string of pad characters. If no second argument is provided, only blank characters are regarded as pad characters.

The return data type of the LTRIM function is based on its source_string argument, using the return type promotion rules that the section Return Types from the CONCAT Function describes.

The value returned contains a substring of source_string, but from which any leading pad characters to the left of the first non-pad character have been removed. If a host variable is used, an LVARCHAR data type is returned.

The LTRIM function scans a copy of the source_string from the left, deleting any leading characters that appear in the pad_string. If no pad_string argument is specified, only leading blanks are deleted from the returned value. When the first non-pad character is encountered, the function returns its result string and terminates.

In the following example, the pad_string is 'Hello':
SELECT LTRIM('Hellohello world!', 'Hello') FROM mytab;
The following table shows the output of this SELECT statement.
(constant)
hello world!
Here the first five characters of the source_string were dropped because they matched characters in the pad_string , but the function terminated after it encountered the lowercase h character, which preserved the trailing 'ello' pad characters to its right.