Precision Problem | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Precision Problem

I got a float value like 73.456002313456 after some calculation .
But I need to have only two values after the decimal point. How to get that value?
With Regards Aruna Mathew
Ignoring any rounding isues here, you can do
SELECT CAST(your_column AS DECIMAL(8,2))
FROM your table

Frank Kalis
Microsoft SQL Server MVP
Heute schon gebloggt?

declare @Loc_Value float select @Loc_Value = (sum(column1)/3) column1 data type is float answer is 73.456002313456
but i want 73.46
i tried with your example……..but didn’t get it With regards Aruna Mathew
I suspect you only want the final result with 2 decimal places. Do this
select @Loc_Value = CAST((sum(column1)/3) AS DECIMAL(4,2)) —
Frank Kalis
Microsoft SQL Server MVP
Heute schon gebloggt?

I think it should be rounded before cast select @Loc_Value = CAST(round((sum(column1)/3),2) AS DECIMAL(12,2)) Madhivanan Failing to plan is Planning to fail
CAST is doing the rounding itself. So I think, unless you don’t want some exotic rounding like Banker’s Rounding, using just CAST is fine. [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />–<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=></a><br />Heute schon gebloggt?<a target="_blank" href=></a><br />
You are correct [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Select 19.0/6 as No ,CAST(19.0/6 AS DECIMAL(12,2)) as Cast_Only,<br />CAST(round(19.0/6,2) AS DECIMAL(12,2)) as Round_and_Cast<br /><br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail