Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2003-10-23 : 17:26:47
|
| Hello All.Does anyone know of a way to show a decimal at a percentage?I want to sho ".6578" as "65.78%".any ideas? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-23 : 17:35:53
|
| select convert(varchar(20),@num * 100) + '%'But should you do this in t-sql or the client?==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2003-10-23 : 17:58:57
|
| That rounds to "65%". I need to display the decimals as well.THis is for use the xp_sendmail and I need to show the percentages on the Email.thanks. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-10-23 : 18:02:33
|
| [code]DECLARE @num DECIMAL(8, 4)DECLARE @percent VARCHAR(8)SET @num = .6574SELECT @percent = CONVERT(VARCHAR(50), @num * 100) + '%'PRINT @percent[/code]But you might want to do this in the front end as Nigel suggested.Tara |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-23 : 18:02:35
|
| ?????declare @num numeric(18,4)select @num = .6578select convert(varchar(20),@num * 100) + '%'65.7800%or maybeselect convert(varchar(20),convert(numeric(18,2),@num * 100)) + '%'65.78%also see str.(and I admit it - Tara types faster than me :) )==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-10-27 : 11:45:23
|
| WOW...2 SECONDSGotta be the record....Damain beat me by three once....Brett8-) |
 |
|
|
|
|
|