Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Manipulation in SQL Statement

Status
Not open for further replies.

RemingtonSteel

Programmer
Jul 14, 2006
65
GB
I am doing a data cleansing and most likely I will be using an update statement.


Tel_Field = 551-9000
Province_Field = Toronto, ON

I want to update a telephone field (with an area code) if the province field is ON.

What is the function I can use for this scenario.

Thanks for your help!
Gene
 
Gene,

How about this:

Code:
UPDATE MyTable ;
  SET Tel_Field = "(999) "  + Tel_Field ;
  WHERE Province_Field = "ON"

where "999" is the new area code.

Or, if old area code is already present:

Code:
UPDATE MyTable ;
  SET Tel_Field = STRTRAN(Tel_Field, "888", "999") ;
  WHERE Province_Field = "ON"

where 888 is the old code.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top