Transact-SQL 参考

LTRIM

删除起始空格后返回字符表达式。

语法

LTRIM ( character_expression )

参数

character_expression

是字符或二进制数据表达式。character_expression 可以是常量、变量或列。character_expression 必须是可以隐性转换为 varchar 的数据类型。否则,使用 CAST 显式转换 character_expression

返回类型

varchar

注释

兼容级别可能影响返回值。有关兼容级别的更多信息,请参见 sp_dbcmptlevel

示例

下例使用 LTRIM 字符删除字符变量中的起始空格。

DECLARE @string_to_trim varchar(60)
SET @string_to_trim = '     Five spaces are at the beginning of this
   string.'
SELECT 'Here is the string without the leading spaces: ' + 
   LTRIM(@string_to_trim)
GO

下面是结果集:

------------------------------------------------------------------------
Here is the string without the leading spaces: Five spaces are at the beginning of this string.             

(1 row(s) affected)

请参见

数据类型

字符串函数