Here are SQL queries of how to use CAST function. From these you will know how to convert CHAR to VARCHAR and DATETIME to DATE.
Refer my part-1 if you miss it.
SQL Cast Function: CHAR to VARCHAR
Example-1
CAST(CHAR-CLMN as VARCHAR(100));
In the second way, CREATE DISTINCT TYPE SAL_1 AS DECIMAL(9,2); This is equal to CAST function.
Example-2
CAST(SAL_1 AS DECIMAL(9,2));
Points to Remember
- You can convert data type into another data type
- Before using it you must understand the rules
- Converting type might impact on the result
- Before you convert INTEGER to STRING read the CAST function rules.
Source: IBM
Here are possible data type conversions and rules.
Related Posts