Link to home
Start Free TrialLog in
Avatar of smssimon
smssimon

asked on

Dealing with Exponent Values in Mssql 2005

create table temp (num float)

insert into temp values (6520008854656651321653)

select * from temp
Returned Result:
num
6.52000885465665E+21

Expected Result:
num
6520008854656651321653


when i insert such large value (6520008854656651321653)  in the column with the data type as float , it gets stored in the exponential format (6.52000885465665E+21).

Now, after a while if i want to get the exact value i have entered, what should i be doing??

Please suggest if there is a way i can store any large value in the table as i give. what is the data type i have to use. Also to be noted,this column is

hugely used for calculation purpose. So, i want it to be stored in a way so that it doesn't hamper the existing calculation logics.
create table temp (num float)
 
insert into temp values (6520008854656651321653)
 
select * from temp 
Returned Result:
num
6.52000885465665E+21
 
Expected Result:
num
6520008854656651321653

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

what if you do:
select cast(num as varchar(30)) from temp 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smssimon
smssimon

ASKER

do you mean use datatype as numeric(24) ??
ok i tried with numeric(24) datatype. Now my question is, since the particular table and its fields are used heavily in calculation, does changing the datatype will effect much ??
the question is, what is the data type you really need.
note that float uses more space than numeric data type,
and hence uses more processing time...
Okei well i have tested with acperkins' suggestion. the test went good. acperkins can you wait for couple of days, currently i m having major demo and i can't test it in real application. I will have the demo finished by 2 days and i want to test it in real application and see the results i get.

Thanx.
>>note that float uses more space than numeric data type<<
angelIII, I beleive that in this particular case float will actually use less space than numeric(24), but that is not the real problem here.