What is RTRIM() in SQL?

The RTRIM() function removes the trailing space characters from a string.

Figure 1 shows a visual representation of the RTRIM() function.

Figure 1: Visual representation of RTRIM() function

Syntax

RTRIM(string)

Parameter

The RTRIM() function takes a string as a parameter.

Return value

RTRIM() removes the trailing space characters from the string sent as a parameter.

Example

The following example shows how to use RTRIM() to remove trailing spaces from words.

To see the changes, highlight both the “Educative” strings in the output.

SELECT "Educative " as BeforeRtrim;
SELECT RTRIM("Educative ") as AfterRtrim;

Free Resources