
February 7th, 2003, 01:07 PM
|
|
Up To His Eyes In Ads
|
|
Join Date: Oct 2002
Location: Chicago
Posts: 160
Time spent in forums: 1 m 25 sec
Reputation Power: 8
|
|
You could do it either place. There's no function (that I know of) in SQL Server to format a percentage. So you have to do it in stages. First you multiple times 100, then Cast as numeric. The numbers in parentheses tell you how many characters to store to the left (10) and the right (2) of the decimal point.
THEN  You have to Cast THAT as a varchar in order to add the non-numeric percent sign. However you may not want the data in a varchar field, in that case just store the data and print the % in your ASP.
Code:
DECLARE @MyNumber FLOAT
SET @MyNumber = '0.0675'
SELECT CAST(CAST(@MyNumber*100 AS numeric(10,2)) AS varchar(5)) + '%'
|