Returns a character expression after removing leading blanks.
LTRIM(character_expression)
varchar
Compatibility levels can affect return values. For more information about compatibility levels, see sp_dbcmptlevel.
This example uses LTRIM to remove leading spaces from a character variable.
DECLARE @string_to_trim varchar(60)
SET @string_to_trim = ' Five spaces are at the beginning of this
string.'
SELECT 'Here is the string without the leading spaces: ' +
LTRIM(@string_to_trim)
GO
Here is the result set:
------------------------------------------------------------------------
Here is the string without the leading spaces: Five spaces are at the beginning of this string.
(1 row(s) affected)
Data Types | String Functions |