Home All Groups Group Topic Archive Search About

Returning numbers formatted as a percent

Author
22 Sep 2005 5:52 PM
Ben
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

Author
22 Sep 2005 6:00 PM
Aaron Bertrand [SQL Server MVP]
SELECT CONVERT(DECIMAL(5,2), 100.0*0.883838)

(You should add the % sign elsewhere, however, IMHO.)


Show quote
"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
>
Author
22 Sep 2005 6:07 PM
Jerry Spivey
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


Show quote
"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
>
Author
22 Sep 2005 6:56 PM
Ben
Thank you both for your quick responses!  I will give them a try as soon as I
can.

thanks again!

Show quote
"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...
> >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
> >
>
>
>
Author
22 Sep 2005 7:40 PM
JT
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.


Show quote
"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
>

AddThis Social Bookmark Button