title: Export sqlplus query result to CSV with Export-CSV
body: <p>I am running some queries in SQLPLUS inside Powershell 2.0</p>
  
  <p>I am wanting to output the content of a table to csv using Export-CSV. 
  It looks something like this.</p>
  
  <pre><code>$query = "set hea off`n"
  
  $date1 = "ADD_MONTHS(TRUNC(SYSDATE, 'MM'),-3))"
  
  $query += "DROP TABLE CHRIS_TEMP;CREATE TABLE CHRIS_TEMP AS SELECT FIELDS FROM TABLES;
  exit;"
  
  $sqlexec = ($query | sqlplus -s login/pass@db)
  
  $sqlexec
  
  $export= ("set wrap off 
  set linesize 30000
  select * from CHRIS_TEMP;" | sqlplus -s login/pass@db ) 
  $export | Export-Csv   c:\users\*****\test.csv -notypeinformation
  </code></pre>
  
  <p>But the output is all one single field.
  Can anyone help with this issue? I would prefer not to spool out CSV in sqlplus.</p>