SQL Data Type Conversion Functions in SAP HANA with Syntax and Examples

SQL Data Type Conversion Functions in SAP HANA with Examples and syntax:-

The SQL Data Type Conversion function in SAP HANA contains something different then the SQL SERVER.Below all the SQL Data Type Conversion functions are explained one by one with examples and with syntax.

1.CAST(<Value/Column/Expression> AS <Data Type>): functions converts the given value to the specified data type.

2.TO_ALPHANUM(<Value>): converts a given value to an ALPHANUM data type.

[AdSense-A]

3.TO_BIGINT(<Value>): This function converts the given value to a BIGINT data type.
Note: If the entered value has decimal points then these digits are truncated during conversion.

4.TO_BINARY(<value>):  function is used to convert the given/source value to a BINARY data type.

5.TO_BLOB(<value>): This function is used convert the given/source value to a BLOB data type.
Note: The source/given value must be a binary string.

6.TO_CLOB(<value>): This function is used convert the given/source value to a CLOB data type.

[AdSense-A]

7. TO_DATE (<Value>,<Format>): This function is used to convert the date values stored in string format into HANA default date format ‘YYYY-MM-DD’. The input should the date string and format how it is stored. If the string date format is in the same format of HANA default or YYYY/MM/DD, then we can skip entering the date format in the input.

8.TO_DATS(<date string>): This function is used to convert the date string values to ABAP DATE string with format ‘YYYYMMDD’.
Note: The source date string value format should HANA default date type i.e ‘YYYY-MM-DD’. If the format is not like HANA default, then we need to use TO_DATE function before be apply TO_DATS.

9. TO_DECIMAL(<value>,<precision>,<scale>): This function is used to convert the given value to the specified precision and scale.

10.TO_DOUBLE(<vale>): This function is used to convert the given string value to double data type.

11.TO_FIXEDCHAR(<string>,<no of characters>): function is used extract the specified number of characters from input string.