Link to home
Start Free TrialLog in
Avatar of Wigging
WiggingFlag for United States of America

asked on

mass update

lets per say that I have a table called   "data"  and inside that table i have a column called " description"

and inside description there is data like  "my website name is www.cholo.com"

and i would like to update  everything that contains  www.cholo.com   change to  www.peru.com ???
Avatar of Vaulden
Vaulden
Flag of United States of America image

You are looking for the UPDATE statement I believe. This should help you out

http://www.techonthenet.com/sql/update.php
ASKER CERTIFIED SOLUTION
Avatar of Habib Pourfard
Habib Pourfard
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To clarify...

If the URL field doesn't contain anything except 'www.cholo.com' then you don't need to use the Replace function..or the %LIKE% in the Where clause, because that would unnecesarily add "cost".

Otherwise Mathewspatricks solution looks good to me.
Just to add another twist into the pot... (because I was hit by this on SQL 2000 and 2005)

If the column data type is ntext (or even text) and your table is huge (I had 250million rows) you may find it faster to export all data out into a file (just row id and that ntext column), do the replace in that file using a free utility like below (don't look at its name - bad choice I guess...) then put it back into SQL.

http://sourceforge.net/projects/fart-it/
If the column data type is ntext (or even text) and your table is huge (I had 250million rows)
If it is text or ntext than they will not be able to use REPLACE on those columns.  At least not without converting them...