SQL Server – LTRIM() and RTRIM() Functions

Usage :

The TRIM function in SQL is used to remove specified prefix or suffix from a string.

This is the most common pattern to remove white spaces.

Syntax :

LTRIM(str): Removes all white spaces from the beginning of the string.

RTRIM(str): Removes all white spaces at the end of the string.

Demo 1

SELECT TRIM(‘ Javadotnet ‘);



Demo 2

SELECT LTRIM(‘ Javadotnet ‘);


‘Javadotnet ‘

Demo 3

SELECT RTRIM(‘ Javadotnet ‘);


‘ Javadotnet’

Categories: SQL

Leave a Reply

Your email address will not be published.