Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I work on sql server 2017 i face issue when save data on float column data type

it saved as IE-07 AND ie-05 so what this and how to handle it please

how to save data on float numbers as it is

if there are any way to save data on correct way on another data type please tell me

my sample data

SQL
create table #numbersfloat
    (
    Numbers float
    )
    insert into #numbersfloat(Numbers)
    values
    (0.0000001),
    (0.00001),
    (0.0000001),
    (0.00001),
    (0.0000001),
    (0.00001),
    (0.0000001),
    (0.00001),
    (10000000),
    (8),
    (1),
    (10000000),
    (14),
    (10000000),
    (1005)


What I have tried:

data on float column data type display as IE so how to solve it and on same time how to save another data as it is
Posted
Updated 4-Jun-22 19:31pm

1 solution

Basically, don't rely on SQL to format your data: if you look at how floating point numbers are stored: Floating-point arithmetic - Wikipedia[^] you will see why you get the results you do.

The SELECT operations return a floating point value not a string: your presentation language should be responsible to how it is displayed, not your database.
 
Share this answer
 
Comments
ahmed_sa 5-Jun-22 4:40am    
how to write query detect numbers like IE only
i need to write query detect numbers like IE only
OriginalGriff 5-Jun-22 4:52am    
Read the link: it's not the number, it's the default string representation of the number.
SQL doesn't "know" you saved it as 0.000001 or 0.1: it just stores it as 1 plus an exponent.

Ignore it and format your data in your presentation language the way you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900