|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hi There
How do I convert the following format 0.0675 to 6.75% is this done at the SQL end or with ASP? Basically I want to update loan rate tables from a local access DB to an SQL 2000 Server DB at our ISP. Any help will be VERY much appreciated TIAV. SEAN. ![]() |
|
#2
|
|||
|
|||
|
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)) + '%' |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Percent Format |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|