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.
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 "
SELECT CAST(
Step 4
Convert and round a floating-point number to an integer using the CAST() function by executing the following query statement, replacing "
SELECT CAST(ROUND(CAST(
Video of the Day