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
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
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
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
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=’

You are correct [<img src=’/community/emoticons/emotion-1.gif’ alt=’

]]>