RTRIM (Transact-SQL)
截断所有尾随空格后返回一个字符串。
RTRIM ( character_expression )
character_expression
字符数据表达式。character_expression可以是常量、变量,也可以是字符列或二进制数据列。character_expression 的数据类型必须可隐式转换为 varchar 否则,请使用 CAST 显式转换 character_expression
varchar 或 nvarchar
兼容级别可能影响返回值。 有关详细信息,请参阅 sp_dbcmptlevel (Transact-SQL)。
以下示例显示如何使用 RTRIM
删除字符变量中的尾随空格。
DECLARE @string_to_trim varchar(60);
SET @string_to_trim = 'Four spaces are after the period in this sentence. ';
SELECT @string_to_trim + ' Next string.';
SELECT RTRIM(@string_to_trim) + ' Next string.';
GO
下面是结果集:
-------------------------------------------------------------------------
Four spaces are after the period in this sentence. Next string.
(1 row(s) affected)
-------------------------------------------------------------------------
Four spaces are after the period in this sentence. Next string.
(1 row(s) affected)
CAST 和 CONVERT (Transact-SQL)
数据类型 (Transact-SQL)
字符串函数 (Transact-SQL)