修剪字符串中的空格 - LTRIM RTRIM 不起作用 [英] Trim spaces in string - LTRIM RTRIM not working

查看:30
本文介绍了修剪字符串中的空格 - LTRIM RTRIM 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个代码 -

UPDATE Table
SET Name = RTRIM(LTRIM(Name))

Name 的数据类型为 varchar(25)

Data type of Name is varchar(25)

前导和尾随空格都不会被删除.当我复制粘贴一个这样的 Name 时,我明白了 -

None of the leading and trailing spaces get removed. When I copy-paste one such Name, i get this -

"big dash" "space symbol" ABC001

为什么会发生这种情况以及如何修剪空格?

Why is this happening and how do trim the spaces ?

编辑 -

问题已经回答了.我又找到了一张有这个问题的表.我得到- 值"当我复制一行的列时.当我在这个复制粘贴值的末尾按下回车键时,我看到更多的破折号.见下图 -

The question has already been answered. I found one more table with this problem. I get "- value" when i copy a column of a row. When I press the enter key at end of this copy-pasted value, i see more dashes. See image below -

推荐答案

我怀疑,名称列中的一些不可读(非 ascii 字符)可能不会作为 TRIM 的一部分被删除电话.

I suspect, some non readable(Non-ascii characters) inside the name column, that might not get removed as part of TRIM calls.

select convert(varbinary, Name) from table

读取上述查询的 HEX 输出应该显示相同的内容.

Reading the HEX output from above query should reveal the same.

请阅读这篇以了解如何编写函数删除这些字符.

Kindly read this to find how to write functions to remove such characters.

这篇关于修剪字符串中的空格 - LTRIM RTRIM 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆