17.10 - Example: Converting Employee Numbers - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

Suppose EmpNo was defined as SMALLINT with the default format of ‘9(6)’. Suppose a value in EmpNo is 12501. The statement:

SELECT EmpNo(CHAR(5)) FROM Employee;

returns the ‘1250’, with a leading pad character and the low order digit missing. The CAST function used for the same conversion, converts to the character representation of the numeric value, trims leading pad characters, and finally truncates or pads on the right. For example, the following SELECT statement returns ‘12501’.

SELECT CAST (EmpNo AS CHAR(5)) FROM Employee;