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 |
|
eurob
Posting Yak Master
100 Posts |
Posted - 2006-02-22 : 12:12:16
|
| When I try to do this calculation:select cast(15969 /2045595 as decimal(5,2)) I get .00I tried it with decimal(38,2).. still the same.Is there a way to calculate the correct result ?robert |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-22 : 12:25:32
|
the result of dividing the 2 integer will be an integer. So you got 0 first before converting to 0.00.Tryselect cast(15969.0 /2045595 as decimal(5,2)) ----------------------------------'KH'It is inevitable |
 |
|
|
eurob
Posting Yak Master
100 Posts |
Posted - 2006-02-22 : 12:54:07
|
| Thanks, it worked.robert |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-23 : 02:18:27
|
| If you use variables, then just multiply it by 1.0Declare @val1 intDeclare @val2 intset @val1=15969set @val2=2045595select cast(@val1*1.0 /@val2 as decimal(5,2))MadhivananFailing to plan is Planning to fail |
 |
|
|
eurob
Posting Yak Master
100 Posts |
Posted - 2006-02-23 : 10:44:31
|
| Thanks.robert |
 |
|
|
|
|
|