Solved

Remove - from phone number

Posted on 2001-07-16
3
204 Views
Last Modified: 2006-11-17
How can I write and update query to remove the dashes from my table.  I have 2 phone number fields that look like this 555-555-5555 I want to remove the dashes.

Thanks
0
Comment
Question by:cat4larry
  • 2
3 Comments
 
LVL 3

Expert Comment

by:trouta
Comment Utility
update person set phone_number = replace(phone_number, '-', '')

if you are running SQL 7.0 or 2000
0
 

Author Comment

by:cat4larry
Comment Utility
Trouta thanks you answered the question one last thing what if the phone number is formated like this (555)-555-5555 how can i remove the () and -'s  thanks very much
0
 
LVL 3

Accepted Solution

by:
trouta earned 25 total points
Comment Utility
either

update person set phone_number = replace(phone_number, '-', '')
update person set phone_number = replace(phone_number, ')', '')
update person set phone_number = replace(phone_number, '(', '')

or

update person set phone_number = replace(replace(replace(phone_number, '-', ''), ')', ''), '(', '')




0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now