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 |
|
agniwoni
Starting Member
28 Posts |
Posted - 2008-01-25 : 04:35:42
|
| If i give SQLSrv following command:SELECT 1/2it will give me:0it is a result in intiger format... What to do to receive:0.5?regardsAgni |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-01-25 : 04:55:34
|
| declare @num realdeclare @num1 realset @num=1set @num1=2select @num/@num1 |
 |
|
|
agniwoni
Starting Member
28 Posts |
Posted - 2008-01-25 : 04:56:47
|
| select 1.0 / 2.0also works!thanks! |
 |
|
|
agniwoni
Starting Member
28 Posts |
Posted - 2008-01-25 : 05:01:12
|
| more!select 1.0/2works!!!!God exists! |
 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-01-25 : 05:27:05
|
quote: Originally posted by agniwoni If i give SQLSrv following command:SELECT 1/2it will give me:0it is a result in intiger format... What to do to receive:0.5?regardsAgni
Yeah it works but you said you want 0.5.The output with your solution 1.0/2.0 is 0.500000.That why I gave you my solution.Else with your solution you can do like this select cast(1.0/2.0 as real) to give output as 0.5 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-28 : 03:56:45
|
| http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|