The BTRIM function trims a string by removing leading and trailing blanks or by removing characters that match an optional specified string.
BTRIM(string [, matching_string ] )
The first input parameter is a VARCHAR string.
The second parameter, if present, is a VARCHAR string.
The BTRIM function returns a VARCHAR string.
The following example trims leading and trailing blanks from the string
select ' abc ' as untrim, btrim(' abc ') as trim; untrim | trim ----------+------ abc | abc (1 row)
The following example removes the leading and trailing
from the string
select 'xyzaxyzbxyzcxyz' as untrim, btrim('xyzaxyzbxyzcxyz', 'xyz') as trim; untrim | trim -----------------+----------- xyzaxyzbxyzcxyz | axyzbxyzc (1 row)
Note that the leading and trailing occurrences of
'xyz' were removed,
but that occurrences that were internal within the string were not removed.