I need to replace some chars in the columns of a table, by using the REPLACE command.
I know that the REPLACE command needs a column name, then the text to change (in the following example, the ‘a’ char) and the new text (in the following case, the ‘e’ char).
UPDATE my_table SET my_column = REPLACE (my_column,'a','e' );
So that executing this command will change all the ‘a‘ occurrences in the my_column column of the my_table table with the ‘e‘ char.
But what if i need to execute the REPLACE command for every column and not just for one? Is this possible?
Thanks
Use the following SQL query to generate the SQL queries that you need to replace a value in all columns.
After executing this SQL query simply run all queries to replace all values.
Untested after some googling
Create a stored procedure with a core like this. It can accept the name of the table, the value to find and the value to replace for.
The main idea is to use:
See partial code (untested) below.