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 |
|
caisys
Starting Member
16 Posts |
Posted - 2007-12-24 : 10:48:08
|
| declare @d dec(9,2)select @d = 55/3select @d as resultresult------18.00How do i get:result-----18.33 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-24 : 10:54:21
|
quote: Originally posted by caisys declare @d dec(9,2)select @d = 55/3.0select @d as resultresult------18.00How do i get:result-----18.33
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-24 : 13:09:29
|
| SQL Server will always implicitly convert result to data type of operands. thats why it strips of decimal part and returns integer result. Making denominator as decimal will implicitly cast the result as decimal.the below link gives an idea on implicit concversions on sql:-[url]http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx[/url] |
 |
|
|
caisys
Starting Member
16 Posts |
Posted - 2007-12-24 : 16:48:57
|
| Thank you both :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-26 : 01:11:50
|
| and if you use variables then multiply it by 1.0select @var1*1.0/@var2MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|