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 2005 Forums
 Transact-SQL (2005)
 sql query

Author  Topic 

shm
Yak Posting Veteran

86 Posts

Posted - 2009-02-09 : 07:16:36
hi

in the query
select 1/8

i wanted to get the result to the query as 0.125 but if i run this it is coming as 0

wt changes i want to do?

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-09 : 07:21:35
select 1*1.0/8

Jai Krishna
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-09 : 07:23:21
Or Use CAST or CONVERT

select cast (1 as numeric(18,3))/8

select convert(numeric(18,3),1)/8


Jai Krishna
Go to Top of Page

shm
Yak Posting Veteran

86 Posts

Posted - 2009-02-09 : 07:42:53
thank u very much it is working..y it is mulitply 1.0
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-09 : 07:49:58
To Cast to float value

Jai Krishna
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-09 : 09:46:23
quote:
Originally posted by shm

thank u very much it is working..y it is mulitply 1.0



http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx
Go to Top of Page
   

- Advertisement -