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



Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied