Banner
Sign Up For
The Cybersalt Digest
Daily Humor and More!!!




(please click only once)
(Pastor Tim values
your privacy
and will not share
your address
with anyone - period!)
Sign Up For
The Cybersalt Digest
Daily Humor and More!!!




(please click only once)
(Pastor Tim values
your privacy
and will not share
your address
with anyone - period!)

Login Form



Who's Online

We have 246 guests online

FAQ Cloud

Find and Replace in SQL Databases
Written by Pastor Tim   
Friday, 02 May 2008 19:29
AddThis Social Bookmark Button

Most of us have used the find and replace function in word processors, but is there a similar feature for finding and things in SQL databases? Yes there is.

First of all, as is always the case, make sure you backup your SQL Database in case something unexpected occurs (especially errors between your keyboard and your seat) while you are working on it.

Next run your database find and replace operation based on the SQL command below:

update TABLENAME SET FIELDNAME = REPLACE(FIELDNAME, 'FIND','REPLACE')

So for instance, let's say that within your database you have a table named "articles" and in that table there is a field named "introduction". If you want to replace (in that field) every occurance of the word "free" with "almost free", the SQL command would look like this:

update articles set introduction = replace(introduction, 'free','almost free')

Just remember to be very careful when you "find and replace" things in your database or you may end up finding and replacing more than you want. The above example will also change everwhere "freedom" occurs to "almost freedom" and you might find your options to repair that mistake to restoring your backup.

Share
 

Add comment


Security code
Refresh

RocketTheme Joomla Templates
The Christian Counter