The Wayback Machine - https://web.archive.org/web/20230124181733/https://www.geeksforgeeks.org/ltrim-function-in-sql-server/
Skip to content
Related Articles
Open in App
Not now

Related Articles

LTRIM() Function in SQL Server

Improve Article
Save Article
  • Last Updated : 16 Dec, 2020
Improve Article
Save Article

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
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!