SQL Server LTRIM function Example

Let’s look at some examples of LTRIM function in SQL Server.

Using LTRIM() function Example

In this example, we will demonstrate the basic use of the LTRIM function in SQL Server.

SELECT LTRIM('       w3wiki');

Output :

w3wiki

LTRIM() function with a variable Example

In this example, we will use the LTRIM function in SQL Server with a variable.

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

Output :

Have a nice time ahead!!

Use of “trim_space” in LTRIM() function Example

In this example, we will remove specific characters from a string using the LTRIM function.

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

Output :

325400

LTRIM() Function in SQL Server

The LTRIM() function in SQL Server removes all the space characters found on the left-hand side of the string. It removes the leading spaces from a string,

Similar Reads

Syntax

The LTRIM function for SQL Server syntax is:...

SQL Server LTRIM function Example

Let’s look at some examples of LTRIM function in SQL Server....

Important Points About SQL Server LTRIM function

The LTRIM() function in SQL Server stands for “left trim” and is used to remove leading spaces (whitespace characters) from a text string. It can also be used to remove specific characters from a string. It helps in cleaning data by removing unnecessary spaces at the beginning of a string....

Contact Us