Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

asked on

how can i update a phone recored in sqlserver (tsql) ?

hello,

i have a table with correct and wrong phone numbers.

wrong phone number : i need to delete the third '0' and keep the rest of the number as it is
+630798214614

here there's no 0 before the 7, there's nothing to do.
+63798214774

what would be the query in order to repair this ?

thank you in advance.
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Can we rely on length ?

because you could do

select left(phone,3) + right(phone,9)
where substring(phone,4,1) = '0'
and len(phone) = 13

Will have a better go at it in a couple of minutes...
Avatar of Erwin Pombett

ASKER

Hello , yes, i think so ,
i'm goign to pass a query in order to check the lenght...

ok. there's spaces for somme of them, so i will remove teh spaces.
can  the following replace space with empty char ?

then for everbody i can remove the where ?

update person
set MobilePhone = replace(MobilePhone, ' ', '')
where personID = '90882'
ASKER CERTIFIED SOLUTION
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yep, you can replace(phone,' ','') for all....



EDIT: gotta duck out for an hour....