SQL - Conversion Functions


In SQL, the conversion functions are used to convert a value from one datatype to another. Generally, the form of the function names follows the convention datatype TO datatype. The first datatype is the input datatype. The second datatype is the output datatype.

List of Functions

Following is a list of functions available in the SQL server for Conversion of one datatype to another −

Sr.No. Function & Description
1 CAST

Is used to transform the numerical data into character or string data.

2 CONVERT

Is used to transform an expression from one data type to another.

3 PARSE

Is used to convert a string data to the desired data format and returns the outcome as an expression.

4 TRY_CAST

Is used to return the expression in the chosen data type.

5 TRY_CONVERT

Is used to change the datatype of an expression.

6 TRY_PARSE

Is used to return a result of an expression that has been converted to the specified data type, or NULL if the conversion is unsuccessful.

sql-conversion-functions.htm
Advertisements