Finding if a field contains all numeric values using Teradata SQL

Scenario: 

How to find if the data contained in a character-type field is all numeric.

Example:

The column contains the following records: '001' and 'ABC'

Solution:

There are three methods to achieve this:

  • TD15.10 supports a TRYCAST('ABC' AS INT) which returns NULL when the cast fails.
  • TO_NUMBER('ABC') also returns NULL for bad data
  • try - where upper(column_name) <> lower(column_name);

dan-irving

posted on 11 Jul 18

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds