Skip to Main Content
  • Questions
  • Format columns correct datatype for CSV output

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Volkenand.

Asked: April 03, 2019 - 12:16 pm UTC

Last updated: April 09, 2019 - 1:32 am UTC

Version: Version 17.4.0.355

Viewed 1000+ times

You Asked

Hello,

I generate in SQL Developer version Version 17.4.0.355 files in CSV format (execute as SQL script).

The table has column values like 2-4 or 9/11, that is in CSV file displayed as 02. Apr.

I tried with
col testcol format 9999 or VARCHAR2 (VARCHAR)
,
but that did not work.

How set the right format commmand syntax that it is correctly displayed as varchar in Spool output format CSV file?

Thanks for help.

and Connor said...

I don't believe this is a SQL Developer issue, but an Excel one.

It is Excel that looks at data and "automagically" decides if the incoming data should become a date.

You can avoid this by doing

- starting Excel
- choose "Get Data from Text"
- the Text Import wizard appears
- in step 3, change "general" to "text" for those columns that might be a problem.


(I'll double check with the SQL Developer PM to see if there is anything we can do at our end)

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

thwarting evil excel wizards

Racer I., April 05, 2019 - 6:31 am UTC

Hi,

Maybe this helps :
https://stackoverflow.com/questions/203807/csv-date-format

> In your CSV file, wrap it with quotes and precede with an equal sign as follows: ="dd/mm/yyyy"

i.e. Excel should not try to interpret anything so quoted.

Maybe if you leave off the qoutes Excel will even recognize this as formulas (assuming those are) and calculate them for you?

regards,
Connor McDonald
April 09, 2019 - 1:32 am UTC

True, but SQL Dev won't do this for you