1

I am inporting a CSV file into SQL Server using the import/export wizard. The data in the CSV file looks like this:

...0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,164051.00,...

All these values are dollar amounts. Since this is packaged finance software (JD Edwards 9.2 to be more precise), I have to live with the data type for all columns being FLOAT and no, I can't change it.

After importing using the wizard, the table has 0 and 164051 respectively in those columns.

When running the pre-packaged JDE finance report, it contains 0 and 1640.51 as the values, i.e. it interprets the last two digits as "cents" and there is nothing I can do about it. Not a problem if the value is 0, but an issue for everything else.

So my only option would be to add two trailing zeroes to the column values after the import. Is there any way this can be done?

If the dollar amount is 16578.98 in the CSV file, it gets imported fine and shows up correctly in the report. The problem is only with even dollar amounts or amounts like 5.80 or 6.10.

Any ideas?

1

If the data is only used for this JDEdwards report, you could simply convert from dollars (164051, 0, 16578.98) to cents (multiply by 100) (16405100, 0, 1657898).

If the data is used in its correct form properly elsewhere, create a view that converts from dollars to cents, and have the JDE report use the view.

If you ever get fractional cents ($12358.9275), then you'd want to round to remove the fractional part. However, I believe that would be an issue now (it'd be reported as $1235892.75, from what you're saying).

0

I'd suggest Importing the data "As-Is" into a staging table, then having a stored procedure that you can use to validate/transform the data into your final destination table(s). That way, you can take care of all the "CAST/Convert/LEFT/RIGHT/etc." functions there.

For that particular conversion, something liek this should work:

 CAST([YourColumnHere] AS DECIMAL(18,2))

Example:

SELECT 
 CAST('18.40' AS FLOAT) FloatExample
,CAST(CAST('18.40' AS FLOAT) AS DECIMAL(18,2)) AS DecimalExample


FloatExample    DecimalExample
------------    --------------
18.4            18.40
0

Have you tried using the advanced properties of the import wizard? check the data type and scale of the column(s). You should be able to explicitly declare your data types, to prevent any implicit conversion. A scale of two should give you two decimal places.

enter image description here

EDIT: I realise that your data type is a float, but this is what is potentially causing you the problem. Try storing the data as a decimal in the database, and let the application do the conversion from decimal to float.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.