Example: Converting Employee Numbers - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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;