One method is it use REGEXP_SUBSTR_ALL to get the array of matching digits, and then turn that array into a string with ARRAY_TO_STRING, which can then be LPAD to 10
SELECT Account_Number_Column
,ARRAY_TO_STRING(REGEXP_SUBSTR_ALL(Account_Number_Column, '\\d'),'') as result_a
,LPAD(result_a,10,'0') as answer_a
FROM VALUES
('00#9999999'),
('000123456M'),
('N/A')
t(Account_Number_Column);
gives:
| ACCOUNT_NUMBER_COLUMN |
RESULT_A |
ANSWER_A |
| 00#9999999 |
009999999 |
0009999999 |
| 000123456M |
000123456 |
0000123456 |
| N/A |
'' |
0000000000 |
Striping the COLLATION off strings is normally bad, BUT given you only want digit's is should ok in this instance to do so via collate(Account_Number_Column,'utf8')
SELECT collate(raw, 'sp-upper') as Account_Number_Column
,lpad(regexp_replace(collate(Account_Number_Column,'utf8'),'[^\\d]*'),10,'0')
FROM VALUES
('00#9999999'),
('000123456M'),
('N/A')
t(raw);
but it should be Jim's answer:
select lpad(regexp_replace(collate(Account_Number_Column,'utf8'),'[^\\d]*'),10,'0');