all groups > sql server programming > september 2006 >
You're in the

sql server programming

group:

Replace



Replace Ata ur Rehman Khan
9/26/2006 11:41:01 PM
sql server programming: I have a filed address in my database in MS Access. There are 8000
recods in the table. I want to remove all the city names from address
field, as i have city name in city field. How can i delete these city
names through SQL?






Re: Replace Arnie Rowland
9/27/2006 12:03:13 AM
The UPDATE is straight forward -especially if the City is separated by a =
comma (or some form of delimiter.)

UPDATE MyTable
SET Address =3D replace( Address, (', ' + City ), '' )

But this would NOT work if there was not a delimiter (comma) AND the =
City name was also part of the address, e.g.,=20

125 Sacramento St Sacramento

Obviously, the above would be a problem IF the comma did not exist.

--=20
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.=20
Most experience comes from bad judgment.=20
- Anonymous


[quoted text, click to view]
AddThis Social Bookmark Button