Use this function to convert a value from one data type to another.

The following source data type conversion functions are supported for CONVERT

Source Can be converted to  
CHAR CHAR, LONG VARCHAR, VARCHAR, BIGINT, DECIMAL/NUMERIC, INTEGER, SMALLINT, DATE, TIME, TTIMESTAMP  
LONG VARCHAR CHAR, LONG VARCHAR, VARCHAR  
VARCHAR CHAR, LONG VARCHAR, VARCHAR, BIGINT, DECIMAL/NUMERIC, INTEGER, SMALLINT, DATE, TIME, TIMESTAP  
BIGINT CHAR, BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
DECIMAL/NUMERIC CHAR, BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
DOUBLE BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
FLOAT BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
INTEGER CHAR, BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT \
REAL CHAR, BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
SMALLINT CHAR, BIGINT, DECIMAL/NUMERIC, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT  
DATE CHAR, VARCHAR, DATE  
TIME CHAR, VARCHAR, TIME  
TIMESTAMP CHAR, VARCHAR, DATE, TIME, TIMESTAMP  

Syntax

SELECT {fn CONVERT(expression, newType)}

Arguments

SELECT {fn CONVERT(expression, newType)}

Returns

The value, converted to the new data type.

Examples

SELECT
{fn convert(SQLSERVER.inventory.dbo.Companies."TotalSales", SQL_DECIMAL)}
AS "TotalSalesDecimal" 
FROM SQLSERVER.inventory.dbo.Companies;