LTRIM() Function in SQL Server
Last Updated :
16 Dec, 2020
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 :
- string – The string from which the leading space character would be removed.
- trim_string – It is an optional parameter that specifies the characters to be removed from the given string.
Returns :
The function will return the string after removing all left-hand side space characters.
Applicable to the following versions of SQL Server :
- SQL Server 2017
- SQL Server 2016
- SQL Server 2014
- SQL Server 2012
- SQL Server 2008 R2
- SQL Server 2008
- SQL Server 2005
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...