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:
- 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 | +------------------+
Please Login to comment...