Open In App

LTRIM() Function in SQL Server

LTRIM() function helps to return remove all the space characters found on the left-hand side of the string.

Syntax :



LTRIM(string, [trim_string])

Parameter :

Returns :
The function will return the string after removing all left-hand side space characters.



Applicable to the following versions of SQL Server :

Example 1 :
The basic usage of the LTRIM() function.

SELECT LTRIM('       GeeksforGeeks');

Output :

GeeksforGeeks

Example 2 :
Using LTRIM() function with a variable.

DECLARE @str VARCHAR(50)
SET @str = '     Have a nice time ahead!!'
SELECT LTRIM(@str);

Output :

Have a nice time ahead!!

Example-3 :
Use of “trim_space” in LTRIM() function.

SELECT LTRIM (‘000325400’, ‘0’);

Output :

325400
Article Tags :
SQL