I am trying to do a simple math equation in SQL Server and cannot figure out why the number is rounding to the nearest integer.
Can someone please tell me what I’m doing wrong?
This should return the value of 2.5, but it always returns 2.
SELECT 225/90 AS RESULT;
DECLARE @R FLOAT
SET @R=225/90
SELECT FORMAT(@R,’N2′) AS FORMAT_RESULT
SELECT FORMAT(225/90,’N2′) AS FORMAT_RESULT
SELECT CONVERT(DECIMAL(10,2),@R) AS CONVERT_RESULT
SELECT CAST(@R AS DECIMAL(10,2)) AS CAST_RESULT
Carolyn Griffin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2