| Author |
Topic  |
|
|
krainov
Yak Posting Veteran
57 Posts |
Posted - 09/28/2012 : 05:09:01
|
Hi there. How to find the "+ 7 (495)" or "+ 7 (499)" or "+7(495)" or "+7(499)" or "+7 (495)" or "+7 (499)" in the varchar field and replace it with "8"? I need to replace the international code in phone numbers with russian formatting for the russian locales of all site materials/publications on the pages.
Thanks! |
|
|
stepson
Yak Posting Veteran
Romania
85 Posts |
Posted - 09/28/2012 : 06:10:04
|
Hi; replace(replace(field ,' ',''),'+7(495)','8')
replace(replace(field ,' ',''),'+7(499)','8')
first replace(field ,' ','') -get rid of then blank/space char then replace your text
S |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1390 Posts |
Posted - 09/28/2012 : 06:10:05
|
UPDATE TableName SET ColumnName = REPLACE ( ColumnName, '+ 7', '8')
-- Chandu |
 |
|
|
krainov
Yak Posting Veteran
57 Posts |
Posted - 09/28/2012 : 06:27:40
|
| Thanks bandi and stepson! It works fine! ) |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1390 Posts |
Posted - 09/28/2012 : 06:31:08
|
Welcome....
You can also update it with single update statement
UPDATE TableName SET Col = case when replace( col, ' ', '') = '7+(495)' then REPLACE ( ColumnName, '+7(495)', '8') when replace( col, ' ', '') = '7+(499)' then REPLACE ( ColumnName, '+7(495)', '8') else col end,
-- Chandu
-- Chandu |
 |
|
| |
Topic  |
|