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)
 how to format/cast with only two decimals

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-11-23 : 20:10:37
I am adding two decimal fields decima(10,2)

but the result column has something like that 23.14500000
I want the result to round to only two decimal places ?

I tried round, but it rounds it however it still lots of ending zeros
23.150000000
how can I make it so it will show 23.15

thank you

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-23 : 20:12:14
Round([Field],2) should only show two decimals. If you are populating a table with more precision than that, it will show zeros after then rounding...

Is this for just a query or is it the resulting table value that you want to switch?




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-23 : 20:13:57
Just re-read that. Incidentally, you can handle formatting on the way out (like in reports and such) rather than worrying about how it is stored (meaning, does it matter if the field stores extra zeroes?, it shouldn't)



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-11-23 : 22:55:01
these results will get feed on an active reports "report", I can take care of the format in there but it will be alot easier if the data comes all set already so the report can just be bind in a couple of statements
Go to Top of Page
   

- Advertisement -