RTRIM will remove trailing spaces from a string. : RTRIM « String Functions « SQL Server / T-SQL Tutorial






3> DECLARE @STRING_WITH_SPACES VARCHAR(30)
4> DECLARE @STRING_WITHOUT_SPACES VARCHAR(30)
5> SET @STRING_WITH_SPACES = "www.java2s.com java2s"
6>
7> SET @STRING_WITHOUT_SPACES = RTRIM(@STRING_WITH_SPACES)
8>
9> SELECT @STRING_WITH_SPACES + "!"
10> SELECT @STRING_WITHOUT_SPACES + "!"
11> GO

-------------------------------
www.java2s.com java2s!

(1 rows affected)

-------------------------------
www.java2s.com java2s!

(1 rows affected)








12.17.RTRIM
12.17.1.RTRIM will remove trailing spaces from a string.
12.17.2.select RTRIM(' SQL Server ')
12.17.3.Removing Trailing Blanks
12.17.4.select LTRIM(RTRIM(' SQL Server '))
12.17.5.RTRIM a column
12.17.6.CONVERT(varchar(20), RTRIM(au_lname) + ', ' + RTRIM(au_fname)