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 |
usafelix
Posting Yak Master
165 Posts |
Posted - 2014-06-30 : 04:56:16
|
I have 100 tables and fields include mobile, fax, telephone. Company request us to restructure of customer their phone number, fax, mobile their pattern from 852-1234 5678 or (852) 1234-5678 or +852 1234 5678 to change in below.Update of Between the number of gap from HK mobile 852-xxxx xxxxcase 1example : 852-1234 5678 result : +852-12345678case 2example : +852-1234-5678result : +852-12345678 case 3 example : (852)-1234 5678result : +852-12345678case 4example : (852) 1234 5678 result : +852-12345678case 5example : (852) 1234-5678result : +852-12345678Please give us advice how I can write a query update all tables ? |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-06-30 : 05:56:39
|
[code]declare @vcTest as varchar(30) = '852-1234 5678'--SET @vcTest ='+852-1234-5678'--SET @vcTest =' (852)-1234 5678'--SET @vcTest ='(852) 1234 5678'SET @vcTest='(852) 1234-5678'SELECT '+' + STUFF(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(@vcTest,' ' ,''),'-',''),'+',''),')',''),'(',''),4,0,'-')[/code]sabinWeb MCP |
|
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-06-30 : 05:57:03
|
output:+852-12345678 sabinWeb MCP |
|
|
|
|
|
|
|