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 |
krainov
Yak Posting Veteran
57 Posts |
Posted - 2012-09-28 : 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
Aged Yak Warrior
545 Posts |
Posted - 2012-09-28 : 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 charthen replace your textS |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-09-28 : 06:10:05
|
UPDATE TableName SET ColumnName = REPLACE ( ColumnName, '+ 7', '8')--Chandu |
|
|
krainov
Yak Posting Veteran
57 Posts |
Posted - 2012-09-28 : 06:27:40
|
Thanks bandi and stepson! It works fine! ) |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-09-28 : 06:31:08
|
Welcome....You can also update it with single update statementUPDATE 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 |
|
|
|
|
|
|
|