Skip to content
Related Articles
Open in App
Not now

Related Articles

SQL Query to Remove Trailing Spaces

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 29 Sep, 2021
Improve Article
Save Article
Like Article

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:

  • string – This is the only required parameter which is a string to remove the trailing spaces.

Applies to:

This function applies to the following databases.

  • SQL Server (all supporting versions),
  • Parallel Data Warehouse
  • Azure SQL Data Warehouse
  • Azure SQL Database,

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  |
+------------------+

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!