How to Convert Doubles to Integers in SQL

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Currency is an example of a floating-point number.

Double-precision floating point numbers are represented by the "float" data type in SQL Server. Occasionally, it may be necessary to convert a floating point number to an integer. This is achieved through the use of the T-SQL "CAST()" function. The "CAST()" function will not automatically round decimals up or down but can be combined with the T-SQL "ROUND()" function if rounding is desired.

Advertisement

Step 1

Open SQL Server Management Studio.

Video of the Day

Step 2

Open a new query window.

Step 3

Convert a floating-point number to an integer without rounding using the CAST() function by executing the following query statement, replacing "" with any floating point number:

Advertisement

SELECT CAST( AS INT)

Advertisement

Step 4

Convert and round a floating-point number to an integer using the CAST() function by executing the following query statement, replacing "" with any floating point number:

SELECT CAST(ROUND(CAST( AS DECIMAL(10,3)), 0) AS INT)

Video of the Day

Advertisement

Advertisement

references & resources