Home > Mobile >  Remove non-numerical values from multiple columns SQL
Remove non-numerical values from multiple columns SQL

Time:12-31

I am a react developer flying solo on a project. I have a sprint item that requests that I remove non numeric values from one of our data columns. I am not really a SQL guy so I am not sure what I am doing and need a little guidance on the syntax for this.

APINumber
30-015-47040
123456789
3001546601
4230134963
30

this is a small sample of what the data looks like, but there are 623 rows total.

the goal is to remove all the dashes from all the rows and just leave the integers.

Update

Via the helpful comments below I was able to run a query and get rid of the dashes, however the change does not persist, when you query the table after, the changes come right back. Is there a way to commit a change via SQL?

After running replace Query:

enter image description here

Then Querying the table: enter image description here

CodePudding user response:

Based on your question edit I think you have misunderstood the comments.

You appear to want to update the data:

update dbo.Well
  set APINumber = replace(APINumber,'-','')
where APINumber like '%-%'

CodePudding user response:

SELECT replace(APINumber,'-','') FROM dbo.Well;

  • Related