RTRIM (T-SQL)

Returns a character string after removing all trailing blanks.

Syntax

RTRIM(character_expression)

Arguments
character_expression
Is an expression of character data. character_expression can be a constant, variable, or column of either character or binary data.
Return Types

varchar

Remarks

character_expression must be of a data type that is implicitly convertible to varchar. Otherwise, use the CAST function to explicitly convert character_expression.


Note Compatibility levels can affect return values. For more information, see sp_dbcmptlevel.


Examples

This example shows using RTRIM to remove trailing spaces from a character variable.

DECLARE @string_to_trim varchar(60)

SET @string_to_trim = 'Four spaces are after the period in this sentence.    '

SELECT 'Here is the string without the leading spaces: ' + CHAR(13) +

    RTRIM(@string_to_trim)

GO

  

Here is the result set:

(1 row(s) affected)

------------------------------------------------------------------------

Here is the string without the leading spaces: Four spaces are after the period in this sentence.          

(1 row(s) affected)

  

See Also
CAST and CONVERT String Functions
Data Types  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.