Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-03-12 : 03:55:40
|
| hello,how do i use a replace funciton in my SP correctlyI am trying to replace the first 3 characters of every phone number inserted to international formatSELECT REPLACE(phone('080%','080','234') from users)phone is the column namethanksAfrika |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-03-12 : 04:43:22
|
| select replace(phone,'080','234') from tableMadhivananFailing to plan is Planning to fail |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-03-12 : 04:51:08
|
| thanks a lot MadhivananAfrika |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-03-12 : 04:52:56
|
| However, a very important questionThe above code you wrote replaces all occurences with 080. I am particular about the first 3 digits and NOT JUST OCCURENCES of 080How do i address this ?Or do i use select replace(phone,'080%','234') fromAfrika |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-03-12 : 05:56:05
|
| Try thisselect phone='234'+substring(phone,4,len(phone)) from table where charindex('080',substring(phone,4,len(phone)))>0MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-03-12 : 06:05:18
|
| Try thisselect phone='234'+substring(phone,4,len(phone)) from table where left(phone,3)='080' |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-03-12 : 06:07:52
|
| oh Ok,i was looking into the case and left functionsBut woudl try that as well |
 |
|
|
|
|
|
|
|