Wednesday, March 21, 2012

exponential value

I am using data flow. source is ole db and target is flat file (csv). I run sql server stored procedure in source and mapped all columns to target file.

Value "-5.0000000000000003E-2" is giving me hard time. It's coming in target file how can remove exponential before writing to target file. In source table that value is coming from float type column. I would like to use some function in select sql if I can.

Thank you - Ashok

Well, that is not a "number" (it's text), so of course you're going to have problems.

How are you extracting from the source table? Do you really need precision to 1e-16? Perhaps you should apply some bounds to the source data before extracting. I think in any application, the value of -0.05 would be appropriate in your case.|||

sorry it's just -5.0000000000000003E-2

I should not have put " in my question.

I have simple select sql in stored procedure which gets that data some thing like select qty from tablename

You are correct I just want -0.05 in my target file.

|||The fact there is an "E" in your data (not to mention the second negative sign) indicates to any parser that the data is text -- most likely.

Regardless, you should convert the data in your SQL statement. Something like this perhaps: (would give you 4 decimal places)

SELECT CAST(qty as decimal(20,4)) as qty
FROM tablename|||

I used CAST(endqty as DECIMAL(10,4)) AS Quantity,in my sql but still get -5.0000000000000003E-2 value in my target file. Looks nothing working I tried to create new table with endqty decimal(18,3) and select from that table but same. when I run stored procedure in management studio I see -0.0500 but in file it not coming same.

when i looked in connection of the .csv file data type is double-precision float [DT_R8] but this is all generated I have not changed any .

Thanks - Ashok

Now I tried change to decimal [DT_DECIMAL] in csv connection for Quantity still same result.

|||

Ashok Ojha wrote:

I used CAST(endqty as DECIMAL(10,4)) AS Quantity,in my sql but still get -5.0000000000000003E-2 value in my target file. Looks nothing working I tried to create new table with endqty decimal(18,3) and select from that table but same. when I run stored procedure in management studio I see -0.0500 but in file it not coming same.

when i looked in connection of the .csv file data type is double-precision float [DT_R8] but this is all generated I have not changed any .

Thanks - Ashok

I'd rebuild the source connections/data flows if possible, using the CAST statement in your source query.|||

I removed whole data flow and connection and strated again.

Now I am in Flat file connection manager edior -> columns and I see Quantity coming as -5.00000000000003E-2 which is not good

when I go in Advanced - DataType I see numeric [DT_NUMERIC] data precision 10 data scale 4

in preview also Quantity coming as -5.00000000000003E-2

Lets see what happen when I run.

You are the man. worked. in target file -.0500

THANK YOU - Phil Brammer
.

No comments:

Post a Comment