且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在SQL Server中删除字符串的空格

更新时间:2023-01-22 19:55:35

正如我在问题的评论中提到的那样,它可能是一个回车符或行尾符号。



找出字符串末尾的char类型的唯一方法是使用 ASCII 函数,它返回ASCII码值。



As i mentioned in the comment to the question, it might be a carriage return or end of line sign.

The only way to find out what kind of char is at the end of string, is to use ASCII function, which return the ASCII code value.

SELECT ASCII(RIGHT(Remarks, 1)) AS LastCharAsciiCode
FROM TableName





现在,当你知道那里有什么样的字符时,你可以更新你的表格!






你可以替换所有不需要的字符



Now, when you know what kind of char is there, you can update your table!

Or

You can replace all unwanted chars

update TableName set Remarks= REPLACE(REPLACE(REPLACE(Remarks,' ',''), CHR(10), ''), CHR(13), '')





祝你好运!



Good luck!