11 July 2018        Add to Favorites   Report

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);


Copied