Sql-server – Rounding of SMALLMONEY Data Type in SQL Server 2005

datatypessql-server-2005

I'm on SQL Server 2005, and I am trying to figure out a rounding issue with smallmoney data types.

For example, the value 1.2849, when rounded to 2 decimal places, produces 1.28, but shouldn't it produce 1.29? e.g. 9 rounds up for 1.285, 5 rounds up for 1.29.

Here is the example:

SELECT
    'CAST(1.2849 AS SMALLMONEY)' OPERATION, CAST(1.284948 AS SMALLMONEY) RESULT
UNION
SELECT
    'ROUND(CAST(1.2849 AS SMALLMONEY), 2)', ROUND(CAST(1.284948 AS SMALLMONEY), 2)
UNION
SELECT
    'ROUND(ROUND(CAST(1.2849 AS SMALLMONEY), 3), 2)', ROUND(ROUND(CAST(1.2849 AS SMALLMONEY), 3), 2)

Best Answer

I am fairly certain that it just looks at the third decimal digit... and that's 4 so it rounds down to 1.28.

Clarify - it looks to the digit one greater than what you are rounding to... so it looks to the third because you are rounding to the second.