Returns a character string after removing all trailing blanks.
RTRIM(character_expression)
varchar
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.
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)
CAST and CONVERT | String Functions |
Data Types |