Remove Hyphens in Oracle SQL

Posted on 2016-09-09
Last Modified: 2016-09-09
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?
Question by:metalteck
  • 3
  • 2
LVL 32

Assisted Solution

awking00 earned 250 total points
ID: 41791594
select replace(ssn,"-",null)
LVL 32

Expert Comment

ID: 41791660
Depending on your version, I believe you can also just do replace(ssn,'-')
LVL 74

Accepted Solution

sdstuber earned 250 total points
ID: 41791663
if it might have other non-numeric characters (spaces, commas, periods, hyphens, etc.)

then try  

LVL 32

Expert Comment

ID: 41791678
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.
LVL 74

Expert Comment

ID: 41791682
if you need to preserve a "P" as well as digits and exclude all others then simply add P to the "keep" list.


Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

820 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