Using Replace in an update command DB2

db2, replace, sql

Solution

I think other experts are overcomplicating the solution that really only requires a simple `UPDATE`:

UPDATE table_name SET column_name = REPLACE(column_name, ' ', '') 
  WHERE column_name LIKE '% %'

Problem

I have a quick requirement in which i need to update the data in my db which is corrupted. I have a few text columns where the text contains &nbsp and although we have fixed the issue in code I still need to correct the corrupted data in db. I think I can do ``` UPDATE table_name SET column_name=( SELECT REPLACE(colum_name, ' ', '') FROM table_name WHERE id=1234) WHERE id=1234 ``` but I will have to do it individually for each row. Is there a easier query which will check all rows in the particular column and remove the &nbsp tag? Thanks for the help.

Original source