Test for numeric value?

前端 未结 3 963
别那么骄傲
别那么骄傲 2021-01-20 17:44

The vendor data we load in our staging table is rather dirty. One column in particular captures number data but 40% of the time has garbage characters or random strings.

3条回答
  •  余生分开走
    2021-01-20 18:31

    Check this out:

    SELECT Mobile, 
     TRANSLATE(Mobile, '~~~~~~~~~~', '0123456789') AS FirstPass, 
     TRANSLATE(TRANSLATE(Mobile, '~~~~~~~~~~', '0123456789'), '', '~') AS Erroneous, 
    REPLACE(TRANSLATE(Mobile, '', TRANSLATE(TRANSLATE(Mobile, '~~~~~~~~~~', '0123456789'), '', '~')), ' ', '') AS Corrected 
     FROM Person WHERE Mobile <> '' FETCH FIRST 100 ROWS ONLY
    

    The table is "Person" and the field that you want to check is "Mobile". If you work a little bit more on this, you can build an UPDATE to fix the entire table

提交回复
热议问题