RTRIM function in SQL Server

The RTRIM function in SQL Server is used to delete all space characters from the last position (the right positions) of the string.

Table of Contents

The article will learn and show you how to use the RTRIM function in SQL Server to delete all space characters from the right positions of the string.

Describe

The RTRIM function in SQL Server is used to delete all space characters from the last position (the right positions) of the string.

Syntax

To use the RTRIM function in SQL Server, we use the following syntax:

 RTRIM(chuoi) 

Parameters :

  1. string : the string you want to cut space characters from the right side. This string must be a character expression or binary data. It can be a string, variable or column.

Note :

  1. See also LTRIM function with the same function but on the right side.
  2. RTRIM function can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.

For example

Take a look and explore some examples of RTRIM functions in SQL Server.

 SELECT RTRIM('TipsMake.com '); 
Result: 'TipsMake.com'

SELECT RTRIM(' TipsMake.com ');
Result: ' TipsMake.com'

SELECT RTRIM('Quan Tri Mang ');
Result: 'Quan Tri Mang'

Previous article: Function RIGHT in SQL Server

Next lesson: SPACE function in SQL Server

You've just finished reading the article "RTRIM function in SQL Server" edited by the TipsMake team. You can save rtrim-function-in-sql-server.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

« PREV : Unique constraints...
RIGHT function in... : NEXT »