简体   繁体   English

SQL Server 2000-如何删除列中的隐藏字符?

[英]SQL Server 2000 - How to remove the hidden characters in the column?

I'm trying to remove a hidden characters from a varchar column, these hidden characters (ie period, space) was taken from a scanned bar code and it is not visible in the result set once query was executed. 我正在尝试从varchar列中删除隐藏的字符,这些隐藏的字符(即句点,空格)是从扫描的条形码中获取的,并且在执行查询后在结果集中不可见。 I have tried to use below script but it failed to remove the hidden characters(see attached screenshot for reference.) 我尝试使用以下脚本,但无法删除隐藏的字符(请参阅所附的屏幕截图以供参考。)

Any help is highly appreciated. 非常感谢您的帮助。

SELECT Replace(Replace(LTrim(RTrim(mycolumn)), '.', ''), ' ', '')
FROM MyTable 
WHERE serialno = '123456789'

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

One thing that has worked for me is to select the column with the special characters, then paste the data into notepad++ then turn on View>Show Symbol>Show All Characters. 对我有用的一件事是选择带有特殊字符的列,然后将数据粘贴到notepad ++中,然后打开“视图”>“显示符号”>“显示所有字符”。 Then I could copy the special characters from Notepad++ into the second argument of the REPLACE() function in SQL. 然后,我可以将Notepad ++中的特殊字符复制到SQL中REPLACE()函数的第二个参数中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM