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 |
|
brandointheweb
Starting Member
2 Posts |
Posted - 2008-06-19 : 03:21:15
|
Hi to all,I'm trying to get a decimal value like 0.75 for later calculating the percentage.But all the time my result is 1. I slowly get frustrated!Can someone give me a hint?My Code: DECLARE @sales decimal ,@sales_dec decimal select @sales = 75 select @sales_dec= CONVERT(DECIMAL(18,2),@sales/100) This code runs in an update trigger which inserts the @sales_dec-value in another decimal(18,2)-column, but only a "1"!Thanks |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-19 : 03:32:50
|
quote: Originally posted by brandointheweb Hi to all,I'm trying to get a decimal value like 0.75 for later calculating the percentage.But all the time my result is 1. I slowly get frustrated!Can someone give me a hint?My Code: DECLARE @sales decimal ,@sales_dec decimal select @sales = 75 select @sales_dec= CONVERT(DECIMAL(18,2),@sales/100) This code runs in an update trigger which inserts the @sales_dec-value in another decimal(18,2)-column, but only a "1"!Thanks
Try this DECLARE @sales decimal ,@sales_dec decimal select @sales = 75 select @sales_dec= CONVERT(DECIMAL(18,2),@sales*1.0/100)select @sales_dec |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2008-06-19 : 03:51:57
|
| [code]DECLARE @sales decimal ,@sales_dec decimal(10,2) select @sales = 75 select @sales_dec= @sales/100.0Select @sales_dec[/code]Chiraghttp://www.chirikworld.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-19 : 04:35:12
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx |
 |
|
|
brandointheweb
Starting Member
2 Posts |
Posted - 2008-06-19 : 09:43:01
|
| Thanks, that worked! |
 |
|
|
|
|
|
|
|