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)
 select query in sql 2005

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2010-10-30 : 02:56:32
Dear Member

i have select a records in table in condition is one colom is not equal to 0 . the column data type is float.
the one row of this column is 0. but i have select row their is some value display like 2.91038304567337E-11 but actual value is 0
i have write following query

select col1,col2 from tabl where col3 <> 0

so please tell me how write query doesn't display this type of records

Kristen
Test

22859 Posts

Posted - 2010-10-30 : 03:43:47
Float will only store an approximation of your number (in many cases). Use DECIMAL datatype if you want an accurate number stored (or MONEY if you are storing monetary values).

You can ROUND your FLOAT column to a specific number of decimal places, and compare that to zero for improved accuracy.

Note that you are comparing col3 of type float with an integer 0, you should use:

select col1,col2 from tabl where col3 <> 0.o

when making a float point comparison against a constant value.
Go to Top of Page
   

- Advertisement -