February 12, 2008 at 2:38 pm
Is there a means to update part of the contents of a field in various rows? Example... field "Street" contains records with the following entries
2210 MacDonald
2212 McDonald
1132 McDonald
1422 MacDonald
The correct required spelling for the street name is MacDonald. I want to do an update to correct all instances where it's spelled incorrectly as McDonald updating it to the correct spelling (MacDonald), but do not want to update the numbers preceding the entry to be changed, as each of those is the correct street number. The resulting data should look like this...
2210 MacDonald
2212 MacDonald
1132 MacDonald
1422 MacDonald
Thanks!
February 12, 2008 at 2:46 pm
You can use "replace" (see Books Online for details).
Sample:
update dbo.Table
set Col1 = replace(Col1, "mcdonald", "MacDonald")
where Col1 like '%mcdonald%'
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
February 12, 2008 at 2:47 pm
Why not just use the replace function?
update mytable
set streetaddress=replace(streetaddress,'McDonald','MacDonald')
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
February 12, 2008 at 3:24 pm
Thanks!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply