How do i write a SQL statement with regular expression that cleans "-" and excess spaces from a number field ?

December 24, 2009 - 9:51 pm

i have a number field that needs cleaning up, for example
1) need to remove dash "-"
2) remove excess spaces in between numbers
3) prefix with some numbers if the length does not meet minimum length
4) remove text if found in the number field.

any help would be appreciated as i am nuts with sql..

1) use replace function
Update home Set address =replace(address,’-',”) From home where address like ‘%-%’

2) replace can work as well
select address , replace(address,’ ‘,”) From home where address like ‘% %’

3) sample:
declare

One Response to “How do i write a SQL statement with regular expression that cleans "-" and excess spaces from a number field ?”

  1. sonya Says:

    1) use replace function
    Update home Set address =replace(address,’-',”) From home where address like ‘%-%’

    2) replace can work as well
    select address , replace(address,’ ‘,”) From home where address like ‘% %’

    3) sample:
    declare
    References :

Leave a Reply