Open In App

SQL Query to Remove Trailing Spaces

In this article, we will look at how to remove trailing spaces. Trailing spaces means the space characters from the right side. We need to use the RTRIM() function. The RTRIM function is used for removing all specified characters from the right-hand side of a string. T

Syntax:



RTRIM(string)

Parameter:

Applies to:



This function applies to the following databases.

Example 1:

Query:

SELECT RTRIM('Geeks for Geeks     ');

Output:

+------------------+
| (No column name) |
+------------------+
| Geeks for Geeks  |
+------------------+

Example 2:

Query:

SELECT RTRIM('   GeeksforGeeks     ');

Output:

+------------------+
| (No column name) |
+------------------+
|   GeeksforGeeks  |
+------------------+

Article Tags :
SQL