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;