在我的一个字段中,我的数据看起来像
- Data with spaces, some other data, .
我把 .在最后你可以看到它有两个空格
我想删除 - 并删除任何和所有双(或更多空格)。将结果保留为一个空格。
并非列中的所有数据都有前导连字符 (-) 其中一些是
Data with spaces, some other data
Data with double spaces, some other data . (double space at end)
Data with leading double space, some other data
- Some data with hyphen, and double space
- double space leading hyphen, some other data
这些是数据库中的少数变体。我试图手动修复每一个,但更正一个条目需要很长时间。
最佳答案
试试这个:
rtrim(ltrim(REPLACE (COLUMN_NAME, '-', ' ')))
我不明白你最后是否需要额外的空间,但如果你确实需要,只需添加 +' '
关于SQL 从数据库中删除前导连字符 (-) 并删除连续的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9455736/