How do I remove non-breaking spaces from a column

2019-01-14 08:05发布

问题:

I'm trying to remove a non-breaking space (CHAR 160) from a field in my table. I've tried using functions like RTRIM() to get rid of it, but the value is still there.

What do I need to do to remove the non-breaking space from the column?

回答1:

Try using REPLACE

UPDATE Your_Table
SET Your_Column = REPLACE(Your_Column, NCHAR(0x00A0), '')
WHERE Id = x


回答2:

You could also use

REPLACE(The_txt, NCHAR(160), ' ')


回答3:

If the above solutions does not work, try CHAR instead of NCHAR

UPDATE Your_Table
SET Your_Column = REPLACE(Your_Column, CHAR(160), '')
WHERE Id = x

CHAR worked for me.