• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Find and replace SQL

Slavik

XenForo moderator
Staff member
#1
I have had a client transfer a Magento to me recently from their old host which was shutting down.

Unfortunately, the old host was unaware of Magento's.... features, and sent me a database that was screwed up big time. I have managed to fix the majority of the damage via a lot of effort. But the final hurdle is replacing a lot of missing quotation marks.

They have all been changed from ' to ’

The problem is, I don't want to have to run a query on 220 individual tables...

So any suggestions on how to run it and search ALL tables for ’ and if found, replace it with '

Im guessing some sort of regular expression... however I will happilly admit, RegEx is something I can't get my head around... I know what it does and how it does it... but not how to form it into something I would use.

Thanks!
 

Brogan

XenForo moderator
Staff member
#2
How big is the database?

Can you export it, open it in an editor and do a find and replace there, then import it again?
 

Brogan

XenForo moderator
Staff member
#4
Can't you run the query on the largest few tables, then export the remainder and do it via an editor?

I don't know Magento but I'm guessing only a handful of tables will make up the majority of the size.
 

Slavik

XenForo moderator
Staff member
#5
Can't you run the query on the largest few tables, then export the remainder and do it via an editor?

I don't know Magento but I'm guessing only a handful of tables will make up the majority of the size.
You might be onto something :) Cheer sBrogan!
 

EasyTarget

Well-known member
#7
Im guessing some sort of regular expression... however I will happilly admit, RegEx is something I can't get my head around... I know what it does and how it does it... but not how to form it into something I would use.

Thanks!
Have you looked at this program
http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/db-repair-tool

If you can export it into a flat file there are plenty of perl scripts out there that can blow throw the file and do a find / replace. I've run scripts like this on >50GB flat files and usually only takes 5-10 minutes to process. YMMV.