0

I am using the Solaris OS. From Solaris I'm logging into SQL*Plus. My database is Oracle 9i.

I am spooling the output of my query into a file. How can I get it in CSV format so that I can copy it into Excel?

My query is like the follwing.

select name,id,location from employee;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
randeepsp
  • 3,572
  • 9
  • 33
  • 40
  • see http://stackoverflow.com/questions/643137/how-do-i-spool-to-a-csv-formatted-file-using-sqlplus – mt_serg Mar 24 '10 at 13:51

1 Answers1

1

I have found a way out of it. We can use concatenation here,

select name,id,location from employee;

gives us 2 different columns, but not in CSV format.

I did

select name||','||id||','||location from employee;

We get the output in a CSV format. It has just concatenated the output with commas (,).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
randeepsp
  • 3,572
  • 9
  • 33
  • 40
  • 2
    Your solution works unless you have commas located in your data. In those instances you will need to double quote the fields. – Dan Mar 29 '10 at 07:26