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 2008 Forums
 Transact-SQL (2008)
 round

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-10-10 : 04:02:24
Stored proc returns data with 2 decimal places i.e.
select
field1 = round(field1, 2),
etc...
The data is shown as 2.45 or 1.5, etc...
If the rounding is 1.50, the system shows it as 1.5
Is there a way to show 1.50 if the rounding gives an answer of 1.5
or 1.60 if the rounding gives 1.6 ?
Thanks

micnie_2020
Posting Yak Master

232 Posts

Posted - 2011-10-10 : 04:05:42
select
field1 = cast(round(1.5, 2)AS decimal(10,2))
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-10 : 04:16:13
You should really leave formatting to the front end application...

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-10 : 04:33:59
you've Format function available in reporting services which you can use for this.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-10-10 : 04:38:51
quote:
Originally posted by visakh16

you've Format function available in reporting services which you can use for this.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/




Hi,
Do you mean in SSRS, the Use regional formatting under Number section in TextBox Properties?
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-10-10 : 04:40:50
quote:
Originally posted by visakh16

you've Format function available in reporting services which you can use for this.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/




Remember that I would like to show 2.30% if the result is 2.3%
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-10 : 04:46:17
you've Format function available, not standard formats inside cell properties

try something like
=Format(Round(Fields!YourField.value,2),"##0.00")

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-10-10 : 13:00:20
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-10 : 14:37:06
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -