11

To convert NON ASCII Characters to ASCII I used the below query

UPDATE tablename
SET columnToCheck = CONVERT(columnToCheck USING ASCII)
 WHERE columnToCheck <> CONVERT(columnToCheck USING ASCII)

It replaces the NON ASCII characters into replacement characters. But is it possible to replace those Non Ascii characters to SPACES.

I tried some options, but its not working. Any suggestion.

1
  • 1
    I came here looking for the query you posted in your initial question. Thanks! Commented Jul 11, 2015 at 16:39

2 Answers 2

16

Try this one

UPDATE tablename
SET columnToCheck = REPLACE(CONVERT(columnToCheck USING ascii), '?', '')
WHERE ...

or

update tablename
set columnToCheck = replace(columnToCheck , char(146), '');

Reference

Sign up to request clarification or add additional context in comments.

1 Comment

If the database is encoded UTF8 (mysql default), the first code will delete all characters with accents, which could be undesirable.
0

I was going to add a comment to M Khalid's answer but the site wont let me but here is a small change to it that prevents removing of ?

UPDATE tablename
SET columnToCheck = REPLACE(CONVERT(columnToCheck USING ascii), '??', '')
WHERE ...

2 Comments

Welcome to StackOverflow. Please, edit and try for How to Answer, describe the effect of what you propose and explain why it helps to solve the problem. Also, you are aware of the need for the commenting privilege, which you do not have. You know the rule ( meta.stackexchange.com/questions/214173/…). In that situation, please do not decide to misuse a different mechanism, an answering post, for what it is not meant for and which you are not yet allowed to do.
Find help with formatting your post here: stackoverflow.com/help/formatting . Consider taking the tour.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.