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)
 Precision and scale of float column in sql table

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2006-07-24 : 08:43:46
While creating new table we can set the properties of column such as
identiy , identity seed,default value ,precision ,scale ,descrption etc.

i have a table having column of float datatype .if i insert the value 112.2 ,by sql it is stored as 112.19494584 some value .
How can i store the the exact value. by setting precision and scale.

precision and scale fields were disabled , when i wanted to change it

Plz suggest the solution

Swati

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-07-24 : 08:53:51
The precision field will be enabled for the datatype like Decimal and Numeric.

I never faced the problem, which you are facing with the Float datatype, can you post
what extactly you were trying to do


Chirag
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-24 : 09:09:59
floating is an approximate value. If you want precision use decimal or numeric.

Refer to BOL for more information.


KH

Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-07-24 : 09:21:04
Swati, you can alos maintain it from front end. while inserting the value, change the format like FormatCurrency, FormatNumber, in case of VB, where u can set precision, scale to u'r value.

BMahesh
Go to Top of Page

gugarc
Starting Member

17 Posts

Posted - 2006-07-25 : 09:34:13
hi - I had the same problem - very often ....
Here we had many money fields set as float - and always when trying to make large reports, we had trouble - because float can not store number as they are (they are allways approximated - due the manner of internal storage ...).

You should use the MONEY data type - or the DECIMAL data type.
Use float only for big numbers, when loosing some precision isn´t a problem.


Go to Top of Page
   

- Advertisement -