Cleaning up bad data in an SQL database

dp, 02 June 2009, View Comments
Categories: Uncategorized
Tags: , ,

Recently, I needed to find all of the data in a table that was being used for HTML output, that had non-printable characters. The following SQL statement should do that for you:

select id, name
from table_name
where name not regexp '^[a-zA-Z0-9_ ,&;\/<>(²):%*#?$|!+.\"\'-]+$;

This code is MySQL specific, but should be applicable anywhere, really.

Related posts:

  1. How to fix strange characters in MySQL database – Vinh Pham I admit, I borrowed this from How to fix strange...
  2. Databases and backups Yesterday, I managed to delete the primary database that we...
  3. gms8994′s benchmark at master – GitHub I’ve recently been posting my benchmark scripts to github. You...

Comments

    blog comments powered by Disqus