I am running some queries in SQLPLUS inside Powershell 2.0
I am wanting to output the content of a table to csv using Export-CSV. It looks something like this.
$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
But the output is all one single field. Can anyone help with this issue? I would prefer not to spool out CSV in sqlplus.
$exportlook like when printed on screen?