| Author |
Topic |
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-02-03 : 13:13:44
|
| I'm currently converting percentages, but doubt if it's the best wayExample: converting .69 to 69.0 via this logicSELECT .69 * 100Perhaps using the CONVERT function?I tried: CONVERT(PERCENT,.69) with no luckShow me the light! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-02-03 : 13:17:11
|
| 69 percent is 00.69 not 69.00. So I think you are talking about the presentation of the data. Most presentation software has lots of numeric and date formatting options. Can you do it there?Be One with the OptimizerTG |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-02-06 : 09:59:44
|
| Thanks TG, yes I'm just trying to make it pretty. Anyone know how to present .69 as %69? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-06 : 10:05:56
|
| If you use Front End Application, why cant you do something like this?value*100 & "%"MadhivananFailing to plan is Planning to fail |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-02-06 : 10:56:43
|
| SQL Server is not for making things "pretty". Query Analyzer is NOT a reporting tool.Use MS Access Data Projects, Crystal Reports, Active Reports, even Excel, and they will be able to display the data the way you like. And chances are they would rather recieve a percentage as 0.69 than as 69.0. |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-02-06 : 11:35:07
|
| No offense blindman, but if you don't want to provide help why post? This is the second time you've added no value. |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-02-06 : 11:37:24
|
| This works:SELECT CONVERT(VARCHAR(20),(.69 * 100)) + '%' |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-02-06 : 11:46:48
|
| Good advice has value. Bad advice does not. I gave him good advice, and I stand by it. If you want to help him avoid "best practices", then maybe that should be your specialty. I promise not to encroach upon your area of expertise... |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-02-06 : 11:52:33
|
| OK |
 |
|
|
jrauls
Starting Member
1 Post |
Posted - 2010-11-30 : 13:43:09
|
| FYI - When percentage set as Varchar, sorting ASC or DESC based on percentages sorts as text, not a number...JD Rauls |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-11-30 : 14:06:06
|
| wow. bumped a 4 yr old post to enlighten us with that? |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2010-12-02 : 13:40:00
|
| Totally worth it to remind me, once again, just how witty and charming I can be when I try.________________________________________________If it is not practically useful, then it is practically useless.________________________________________________ |
 |
|
|
moonshiner
Starting Member
1 Post |
Posted - 2012-01-24 : 17:01:21
|
| Best practice IMHO would be:cast(convert(money,(0.69*100)) as varchar(max)) + '%'this way he gets a consistent 2 decimal place for all responses. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-24 : 18:06:52
|
quote: Originally posted by moonshiner Best practice IMHO would be:cast(convert(money,(0.69*100)) as varchar(max)) + '%'this way he gets a consistent 2 decimal place for all responses.
Are you trolling?If so, respect! that's pretty witty.If you are serious........ no, no, no, no, no.do it in the front end, why turn your expensive database server into a string.format whore?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|