I'm using a data warehouse and I need to remove a bunch of cases from a phone number column to be able to use it as a lookup on another data source. Some cases of what the data looks like:
888-888-8888 ---> should be 888888888
(888) 888-8888 ---> should be 888888888
888.888.8888 ---> should be 888888888
888-888-888 ext 888 ---> should be 888888888
1-888-888-888 ---> should be 888888888
888 88 8888 888888 ---> should be 888888888888888
I am able to do multiple replace statements to get rid of the simple characters like -, ., (, ). The part I'm having trouble with is removing the ' ext 888' and the '1-' where the number starts with '1-' (not contains). The 888 could be any numbers and it could be any amount of digits. Dealing with user-entered information and multiple countries.
Is there anything available that I can write in SQL that could accomplish those last 2 parts?