?
Solved

Remove - from phone number

Posted on 2001-07-16
3
Medium Priority
?
220 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 100 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

650 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