sql有没有去掉空格的函数?

zhmvb 2004-12-03 03:20:34
我做了一个插寻,但发现没个字段都带有空格,所以找不出数据,有没有去掉空格的函数?
...全文
599 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yelook 2004-12-03
  • 打赏
  • 举报
回复
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)

Liroyal 2004-12-03
  • 打赏
  • 举报
回复
ltrim(@String)
rtrim(@String)
replace(@String, ' ', '')
jiang130 2004-12-03
  • 打赏
  • 举报
回复
ltrim(rtrim(字段))
yelook 2004-12-03
  • 打赏
  • 举报
回复
ltrim ,rtrim

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧