|
-
Dec 22nd, 2005, 08:23 AM
#1
Thread Starter
Frenzied Member
Update a word in entire table [RESOLVED]
Hello everybody,
Someone generated SQL script for data migration and misspelled the word "Install" with "Instal". This is only in one field of a table but the table contains massive records.
Is there some way to write a script to update Title field in such a way if it contains the word Instal, it should be replaced with Install. I have seen Instal is at the end of the other data.
For example:
abc
abc2
xyz Instal
xyz2Instal
This field should be:
abc
abc2
xyz Install
xyz2Install
Thanks.
Last edited by usamaalam; Dec 22nd, 2005 at 09:17 AM.
-
Dec 22nd, 2005, 08:32 AM
#2
Re: Update a word in entire table [URGENT]
Code:
UPDATE abc SET field = 'xyz Install' WHERE field = 'xyz Instal'
-
Dec 22nd, 2005, 08:39 AM
#3
Re: Update a word in entire table [URGENT]
Or this will work too:
UPDATE tblSample SET Field = REPLACE (Field, 'Instal', 'Install')
Mind you, it applies a wild card on both sides of 'Instal', so correct spelling in that field will have 3 L's.
Last edited by sevenhalo; Dec 22nd, 2005 at 09:18 AM.
-
Dec 22nd, 2005, 09:17 AM
#4
Thread Starter
Frenzied Member
Re: Update a word in entire table [URGENT]
Thanks.
sevenhalo's code is useful for me because data contains different words before Instal like "Store 1302 Instal" or "Store 6957 Instal" etc.
-
Dec 22nd, 2005, 09:19 AM
#5
Re: Update a word in entire table [RESOLVED]
What about the fields where Install (with two Ls) was originally there?
-
Dec 22nd, 2005, 09:35 AM
#6
Re: Update a word in entire table [RESOLVED]
 Originally Posted by mendhak
What about the fields where Install (with two Ls) was originally there?
They would be skipped.
-
Dec 22nd, 2005, 10:06 AM
#7
Re: Update a word in entire table [RESOLVED]
Hack - I think he was reffering to my example. It will over-correct if it's not a universal problem.
Mend - I threw in a disclaimer so they knew ahead of time. I guess you could get really dirty and throw in another statement afterwards:
UPDATE tblSample SET Field = REPLACE (Field, 'Installl', 'Install')
Or, if you want to be clean and proper, you could make a sproc that will work (and maybe even abstract it enough so that it can be used on future issues).
Me... I preffer to be dirty.
-
Dec 22nd, 2005, 03:01 PM
#8
Re: Update a word in entire table [RESOLVED]
I like that.
-
Dec 22nd, 2005, 03:14 PM
#9
Thread Starter
Frenzied Member
Re: Update a word in entire table [RESOLVED]
I did the same thing. Ran second script to replace any Installl with Install.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|