Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I am rounding numbers to 2 decimal places.How is it possible to get the 0 at the end also?For example, rounding 8.1243 gives 8.12But rounding 6.4 gives 6.4 whereas I would like to see 6.40OR if the answer is say 2 I would like to see 2.00How is this done please?Thanks
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-08-20 : 10:05:04
Use DECIMAL. That would round it as well by default.
DECLARE @x FLOAT = 2.0;SELECT ROUND (@x,2);SELECT CAST(@x AS DECIMAL(19,2))
arkiboys
Master Smack Fu Yak Hacker
1433 Posts
Posted - 2012-08-20 : 13:26:28
Thanks
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2012-08-20 : 13:53:40
Just to add to what Sunitbeck said, if you pass in a numeric/decimal, you'll get that same datatype back out.