Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SQL Query to Remove Trailing Spaces

  • Difficulty Level : Medium
  • Last Updated : 29 Sep, 2021

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
Recommended Articles
Page :

Start Your Coding Journey Now!