Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 decimals

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2010-09-23 : 16:57:57
this code


select (round(1.985, 3, 1) * 1000)


give me 1985.000

How can I make it

1985.00

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-09-23 : 17:10:48
I belive that SQL thinks 1.985 is a decimal(p, 3) where p is the precision. So the return type of ROUND is also decimal(p,3). Try CASTing the whole thing as the appropriate decimal precision and scale. For example:
select CAST((round(1.985, 3, 1) * 1000) AS DECIMAL(18,2))
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2010-09-23 : 17:24:54
Yes, that did it. Thanks!
Go to Top of Page
   

- Advertisement -