SQL Script to alter data format

Currently have a column in the database that is char (20) in the following format
999-99-9999 to represent a phone number however this value needs to be imported into another database where the format is char (13) and shown as 999999999

Is there a sql script that can be run to remove the dashes from the column or to copy just the numbers from this column to a new column>
fireprograms_techAsked:
Who is Participating?
 
BanthorConnect With a Mentor Commented:
There are too many possible answers.
update Table set [telcol] = replace([telcol],'-','') Will remove the dashs but will not validate the output.
you can use the statement as a select

SELECT
  replace([telcol],'-','')
from
  Table

and locate issues as

SELECT telcol, *
 from table
where 1=0
  or LEN(replace([telcol],'-','')   !=  9
  or isnumeric(replace([telcol],'-','') ) = 0
0
 
HainKurtSr. System AnalystCommented:
select replace ('999-99-9999','-','')
999999999
0
 
fireprograms_techAuthor Commented:
Thank you so much this completely resolved the issue I was having with the database,  I was able to create a new column and then run the update formula and move the edited data to the new column.  Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.