RTRIM: trim the white space to the right : RTRIM « Subquery « SQL Server / T-SQL






RTRIM: trim the white space to the right


12>
13>
14> -- LTRIM() and RTRIM() Functions
15>
16> -- Return a string with white space (spaces) trimmed
17>
18> DECLARE @Value1 Char(10), @Value2 Char(10) SET @Value1 = 'One'
19> SET @Value2 = 'Two'
20> SELECT @Value1 + @Value2
21> SELECT CONVERT(VarChar(5), LEN(@Value1 + @Value2)) + ' characters long.'
22> SELECT RTRIM(@Value1) + RTRIM(@Value2)
23> SELECT CONVERT(VarChar(5), LEN(RTRIM(@Value1) + RTRIM(@Value2)))
24>        + ' characters long trimmed.'
25> GO

--------------------
One       Two

(1 rows affected)

----------------------
13 characters long.

(1 rows affected)

--------------------
OneTwo

(1 rows affected)

------------------------------
6 characters long trimmed.

(1 rows affected)
1>
2>
           
       








Related examples in the same category

1.RTRIM: remove trailing spaces from a string
2.RTRIM: trim string on the right
3.RTRIM(city),30)