-2

I have a Phone number column in my table with values only being numbers and no special characters. for one of the column I got a value coming in as ":1212121212".

I will need to filter this record and any records coming in with any special characters in teradata. Can anyone help on this.

I have tried the below solutions but it is not working

where (REGEXP_SUBSTR(column_name, '[0-9]+')<>1 or column_name is null )

2 Answers2

0

In MS SQL Server DB's, you can use TRYCAST to find those entries having non numeric characters:

SELECT column_name 
FROM yourtable
WHERE TRY_CAST(column_name AS INT) IS NULL;

In Teradata DB's, you can use TO_NUMBER:

SELECT column_name 
FROM yourtable
WHERE TO_NUMBER(column_name) IS NULL;

If you want to stay close to your attempt, can use LIKE to find not numeric entries:

SELECT column_name 
FROM yourtable
WHERE column_name LIKE '%[^0-9]%';

Note this could get slow when your table has very many rows.

Jonas Metzler
  • 4,517
  • 1
  • 5
  • 17
0

Thanks Jonas. Since I need only numeric values and the length should be 10, I tried the below and it worked. This would ignore all the additional special characters.

(regexp_similar(Column,'[0-9]{10}')=1)