SQL Server : Removes Leading Spaces from a String

LTRIM() Function

The LTRIM() function is commonly used to remove spaces at the beginning (left) of a text string.

Syntax:

LTRIM(text)

e.g.

DECLARE @String VARCHAR(50) = '   Learn to be happy right now!    '

SELECT LTRIM(@String) TrimmedText


In the example above there are spaces at the beginning and at the end of the text. Because we use LTRIM, the spaces are omitted only at the beginning (left side)


Also, read the following posts:

Removes Leading and Trailing Spaces from a String (TRIM)

Removes Leading Spaces from a String (LTRIM)

Removes Trailing Spaces from a String (RTRIM)

Post a Comment

0 Comments