Remove - from phone number

Posted on 2001-07-16
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.

Question by:cat4larry
  • 2

Expert Comment

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

if you are running SQL 7.0 or 2000

Author Comment

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

Accepted Solution

trouta earned 25 total points
ID: 6287565

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


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


Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 34
SQL Server 2012 r2 - Sum totals 2 22
hyperlink data type in SQL 3 23
[SQL server / powershell] bulk delete table from CSV 8 29
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

813 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

12 Experts available now in Live!

Get 1:1 Help Now