Saturday, February 25, 2012

Returning numbers formatted as a percent

I have a stored procedure that feeds a graph in an access ADP, and the
numbers are being sent as 0.883838.... can i format the number being
returned from the stroed procedure to a percent? (ie 88.38%)? and also, how
do i limit the number of decimal places? the columns being used in the
calculations are of type decimal.
thanksSELECT CONVERT(DECIMAL(5,2), 100.0*0.883838)
(You should add the % sign elsewhere, however, IMHO.)
"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:72D396F4-78AD-4AA5-932C-F998ECEB61D7@.microsoft.com...
>I have a stored procedure that feeds a graph in an access ADP, and the
> numbers are being sent as 0.883838.... can i format the number being
> returned from the stroed procedure to a percent? (ie 88.38%)? and also,
> how
> do i limit the number of decimal places? the columns being used in the
> calculations are of type decimal.
> thanks
>|||Ben,
If you are adding the % symbol via t-sql for ad-hoc reports, you could try:
select convert(varchar(20),convert(decimal(8,2)
,column*100)) + '%' from
table
HTH
Jerry
"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:72D396F4-78AD-4AA5-932C-F998ECEB61D7@.microsoft.com...
>I have a stored procedure that feeds a graph in an access ADP, and the
> numbers are being sent as 0.883838.... can i format the number being
> returned from the stroed procedure to a percent? (ie 88.38%)? and also,
> how
> do i limit the number of decimal places? the columns being used in the
> calculations are of type decimal.
> thanks
>|||Thank you both for your quick responses! I will give them a try as soon as
I
can.
thanks again!
"Jerry Spivey" wrote:

> Ben,
> If you are adding the % symbol via t-sql for ad-hoc reports, you could try
:
> select convert(varchar(20),convert(decimal(8,2)
,column*100)) + '%' from
> table
> HTH
> Jerry
>
> "Ben" <ben_1_ AT hotmail DOT com> wrote in message
> news:72D396F4-78AD-4AA5-932C-F998ECEB61D7@.microsoft.com...
>
>|||If you pre-format the column as a varchar with symbols, then whatever
application is consuming the rowset may have trouble summing, averaging, or
applying their localized formatting.
"Ben" <ben_1_ AT hotmail DOT com> wrote in message
news:72D396F4-78AD-4AA5-932C-F998ECEB61D7@.microsoft.com...
>I have a stored procedure that feeds a graph in an access ADP, and the
> numbers are being sent as 0.883838.... can i format the number being
> returned from the stroed procedure to a percent? (ie 88.38%)? and also,
> how
> do i limit the number of decimal places? the columns being used in the
> calculations are of type decimal.
> thanks
>

No comments:

Post a Comment