How to Convert an Integer to a Decimal in SQL Server Database: MS SQL Server Operators: CAST() CONVERT() Table of Contents Problem Solution 1 Discussion Solution 2 Problem You’d like to convert an integer value to a DECIMAL data type in SQL Server. Let’s convert an integer to the DECIMAL data type. Solution 1 We’ll use the CAST() function. Here’s the query you’d write: SELECT CAST(12 AS DECIMAL(7,2)) AS decimal_value; Here is the result: decimal_value 12.00 Discussion Use the CAST() function to convert an integer to a DECIMAL data type. This function takes an expression or a column name as the argument, followed by the keyword AS and the new data type. In our example, we converted an integer (12) to a decimal value (12.00). The displayed value has two decimal points because DECIMAL in CAST() has two decimal points. SQL Server provides another option: CONVERT(). This is not a SQL Standard function like CAST(). The query below shows its use. Solution 2 Here’s another way to convert an integer to a DECIMAL type: SELECT CONVERT(DECIMAL(7,2), 12) AS decimal_value; This query produces the same result as CAST(), but takes two mandatory arguments: the data type and an expression, value, or column name to convert. An optional third parameter specifies how the value should be formatted in its new type. Read more about value formatting in the official SQL Server documentation. If you don’t need to return the value in a certain format, use CAST(). Recommended courses: SQL Basics in SQL Server SQL Practice Set in MS SQL Server Common Functions in SQL Server Recommended articles: SQL Server Cheat Sheet Top 29 SQL Server Interview Questions How to Learn T-SQL Querying 5 SQL Functions for Manipulating Strings 18 Useful Important SQL Functions to Learn ASAP 15 SQL Server Practice Exercises with Solutions See also: How to Convert a String to a Numeric Value in PostgreSQL How to Change Datetime Formats in MySQL How to Change Seconds to a Time Value in MySQL How to Change Date and Time Formats in T-SQL Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query