When working with database system converting data between different data types is one of the tasks ETL developers find themselves doing very often. It is highly recommended to keep datatypes the same and use the front end to modify the format during presentation. This is not always possible. In such cases you can use the CONVERT Function as shown below to change the data from one datatype to another. Keep in mind that we aren’t changing the format but the actual data type. E.g. here we change a decimal number of 2.012 into the integer 2

The below screenshot shows the different target datatypes the value can be converted into.

This function is especially useful for cases when you need to concatenate the value with a string we will show in the next post.

The SQL equivalent is

SELECT CONVERT(int, 1234.982)


Leave a Reply