删除字段内容中的尾随空白
我正在使用 SQL Server MSDE 2000。我有一个名为 notes
的 nvarchar(65) 类型字段。
所有记录中的内容都是“Something”,内容后面有一个额外的空格(为了清晰起见,用引号引起来)。我使用了以下命令。
UPDATE TABLE1
SET notes = RTRIM(LTRIM(notes))
但这不起作用。有没有其他方法可以做到这一点?
I am using SQL server MSDE 2000. I have a field called notes
of type nvarchar(65).
The content is 'Something ' with an extra space after the content (quotes for clarity) in all the records. I used the following command.
UPDATE TABLE1
SET notes = RTRIM(LTRIM(notes))
But it does not work. Is there any alternate way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确定查询不起作用吗?尝试:
TOP 100
将结果限制为前 100 行,足以了解输出中是否确实存在空格。如果有,并且 RTRIM/LTRIM 没有删除它 - 那么您没有处理空白字符。在这种情况下,请尝试:Are you sure the query isn't working? Try:
TOP 100
will limit the results to the first 100 rows, enough to get an idea if there's really a space in the output. If there is, and RTRIM/LTRIM is not removing it - then you aren't dealing with a whitespace character. In that case, try:...或者您实际上可以复制/粘贴空白“ ” (空格)作为查询替换语句的结果出现在字段末尾,并从那里更新所有内容。
... OR you could literally just copy/paste the blank ' ' (space) at the end of a field as a result of your query into your replace statement and update everything from there.
如果您需要修剪所有列中的所有空格,您可以使用此脚本动态执行此操作:
And just in case you need to TRIM all spaces in all columns, you can use this script to do it dynamically: