RTRIM() Function in SQL

SQL RTRIM() function allows us to remove the trailing empty spaces from the string. Trailing white spaces are the redundant white spaces present at the right end of the string. For example, In “GFG “, there are 5 empty white spaces at the right end of the string.

If there are redundant white spaces at the beginning of the string. For example: ” GFG”, there are 5 whitespaces at the beginning of the string”, these are called leading whitespace.

RTRIM function works in: MySQL 4.0, SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse, Oracle, and all other major database systems.

SQL RTRIM() Function

SQL RTRIM function is a string function that removes spaces from the right side of a character or string. RTRIM or Right Trim function is used in data cleaning and manipulation in SQL.

In this example, we will learn the basics of the RTRIM function, and learn how it works with examples of different use cases.

Similar Reads

RTRIM() Function in SQL

SQL RTRIM() function allows us to remove the trailing empty spaces from the string. Trailing white spaces are the redundant white spaces present at the right end of the string. For example, In “GFG “, there are 5 empty white spaces at the right end of the string....

Syntax

RTRIM( input_text); OR RTRIM(column_name) AS trimmed_nameFROM table_name;...

SQL RTRIM Function Examples

Let’s see some examples of RTRIM function in SQL, and understand it’s working with examples of different use cases....

Key Takeaways About SQL RTRIM Function

RTRIM() function removes the trailing spaces in the given string or removes trailing spaces for all the values present in a specific column in the table. It allows only one parameter i.e. either a string or a column having values of string type. It is supported in all major database systems. When used in SELECT statements, the function improves the readability of results by eliminating unnecessary white spaces....

Contact Us