Remove Hyphens in Oracle SQL

I have a ssn field.
The field has hyphens in it.
Ex. xxx-xx-xxxx

How can I just extract the numbers without the hyphens?
metalteckAsked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
if it might have other non-numeric characters (spaces, commas, periods, hyphens, etc.)

then try  

regexp_replace(ssn,'[^0-9]')
0
 
awking00Connect With a Mentor Commented:
select replace(ssn,"-",null)
0
 
awking00Commented:
Depending on your version, I believe you can also just do replace(ssn,'-')
0
 
awking00Commented:
It's quite common to express ssn in the xxx-xx-xxxx format and I suspect eliminating the hyphens may be all that's needed. There is also something called a PTIN (stands for preparer tin) that begins with the letter "P" which wouldn't be retained if just the digits are retrieved.
0
 
sdstuberCommented:
if you need to preserve a "P" as well as digits and exclude all others then simply add P to the "keep" list.

regexp_replace(ssn,'[^0-9P]')
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.