Query to get only numbers from a string

前端 未结 14 2424
野性不改
野性不改 2020-11-22 06:17

I have data like this:

string 1: 003Preliminary Examination Plan   
string 2: Coordination005  
string 3: Balance1000sheet

The output I exp

14条回答
  •  攒了一身酷
    2020-11-22 06:21

    I did not have rights to create functions but had text like

    ["blahblah012345679"]
    

    And needed to extract the numbers out of the middle

    Note this assumes the numbers are grouped together and not at the start and end of the string.

    select substring(column_name,patindex('%[0-9]%', column_name),patindex('%[0-9][^0-9]%', column_name)-patindex('%[0-9]%', column_name)+1)
    from table name
    

提交回复
热议问题