Sql-server – Need FLOAT datatype with 2 digits after decimal point when importing from a CSV file

importsql serversql-server-2008-r2

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?

Best Answer

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).