Solved

Remove - from phone number

Posted on 2001-07-16
3
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:trouta
ID: 6287504
update person set phone_number = replace(phone_number, '-', '')

if you are running SQL 7.0 or 2000
0
 

Author Comment

by:cat4larry
ID: 6287559
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
ID: 6287565
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

697 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