EmersonH.Com

Transforming Knowledge into Power

  • Increase font size
  • Default font size
  • Decrease font size
Home T-Sql Trim Function

Trim Function

E-mail Print

TRIM([[LOCATION] [remstr] FROM ] str): [LOCATION] can be either LEADING, TRAILING, or
BOTH. This function gets rid of the [remstr] pattern from either the beginning of the string or the end
of the string, or both. If no [remstr] is specified, white spaces are removed.
LTRIM(str): Removes all white spaces from the beginning of the string.
RTRIM(str): Removes all white spaces at the end of the string.


Example 1:
SELECT TRIM(' Sample ');
Result:
'Sample'


Example 2:
SELECT LTRIM(' Sample ');
Result:
'Sample '


Example 3:
SELECT RTRIM(' Sample ');
Result:
' Sample'