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
 SQL Server Development (2000)
 Float to Numeric

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-27 : 08:00:55
anuraj writes "Hai

I am facing a problem like below
SELECT CONVERT(FLOAT,1.0/15.0)
gives a result like this
6.6666000000000003E-2
But I want the result like this
0.066666666666666666666666666666667

Please help me

thanks and regards
anuraj

SQL Server : 7.0
MS Windows 2000, SP 4.0"

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-10-27 : 09:14:32
Hope this helps you ..

Select Cast(1.0/15.0 As Numeric(10,10) )

Complicated things can be done by simple thinking
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-10-27 : 09:47:41
This should do it:

select Result= convert(float,1.0)/convert(float,15.0)

Result
-----------------------------
6.6666666666666666E-2

(1 row(s) affected)






CODO ERGO SUM
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-10-28 : 03:14:45
Probably as close as one can get without going the right direction and use the client for such formatting issues, you might do

select STR(convert(float,1.0)/convert(float,15.0),18,18)

------------------
0.0666666666666667

(1 row(s) affected)


--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon geblogged? http://www.insidesql.de/blogs
Ich unterstütze PASS Deutschland e.V. (http://www.sqlpass.de)
Go to Top of Page
   

- Advertisement -