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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Datatype

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-07-06 : 02:29:34
Dear all,
In the following Select statement returns 0 but this values is 0.1 Why it's return 0
select 1/10

Thanks
KK

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-06 : 02:40:12
Because of implicit conversion to int datatype
Try using

Select 1/10.0



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-07-06 : 02:42:15
Yes It's working
Here What is the reason to pake an implicit conversion..?

Thanks
-- KK
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-06 : 02:42:40
because int divide by int is int. So 1 / 10 is 0


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-06 : 02:46:46
If both are of intergers and divisor is more than dividend then the result is 0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-07-06 : 02:51:34
Thanks Gurus

-- KK
Go to Top of Page
   

- Advertisement -