Back to blog

Using REPLACE in an UPDATE statement to fix data on MSSQL and MySQL

Sometimes it’s necessary fix data on the database. I had to fix on a Microsoft database: /* MSSQL syntax */…

Sometimes it’s necessary fix data on the database.
I had to fix on a Microsoft database:

      /* MSSQL syntax */
      update table_links set url  = Replace(url, 'www.link.it/web3', 'www.link.it/web') where url <>''

I had to fix on a MySQL database:

      /* MySQL syntax is the same! */
      UPDATE table_links SET url =REPLACE(url, '&amp;', '&') where url<>''

The syntax is the same.

Canonical URL