简体   繁体   English

RTRIM不会在末尾删除空格吗?

[英]RTRIM does not remove spaces at the end?

I have used the Query: 我用过查询:

    update Table
    set Seg = RTRIM(Seg)

This still doesn't remove the extra spaces at the end? 这仍然不会删除多余的空格吗? I really need to remove this as I am doing vlookups in Excel and it is causing problems. 我真的需要在Excel中执行vlookups时将其删除,这会导致问题。

The datatype of Seg column is (nchar(10), null) Seg列的数据类型为(nchar(10),null)

Any help is appreciated. 任何帮助表示赞赏。

You can right-trim an NCHAR(X) column all you want, values will always be the same length. 您可以根据需要右修剪NCHAR(X)列,值始终是相同的长度。 Namely: X . 即: X The value will always be padded with spaces, so RTRIM is basically a no-op on a fixed width character column. 该值将始终用空格填充,因此RTRIM基本上是固定宽度字符列上的禁止操作。

Also note that in string comparisons, trailing spaces are ignored. 另请注意,在字符串比较中,尾随空格将被忽略。

To trim spaces from the end you should use 要从尾部修剪空间,应使用

UPDATE TableName SET ColumnName = RTRIM(ColumnName) 更新TableName SET ColumnName = RTRIM(ColumnName)

if you want to trim all spaces then use this 如果要修剪所有空间,请使用此

UPDATE TableName SET ColumnName = LTRIM(RTRIM(ColumnName)) 更新TableName SET ColumnName = LTRIM(RTRIM(ColumnName))

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

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