3

I want to execute query from batch file and put exact output of query into csv file. Like: my query is : select sysdate from dual. Output of this :

Sysdate
23-feb-2013

So, in csv it stored as

sysdate
22-feb-2013

DB: Oracle 11g OS: windows 7

Kindly plz help me to achieve this ..

1 Answer 1

2

c:\myfolder\mybatch.bat:

call sqlplus oracleuser/oraclepwd@oracledb @c:\myfolder\myquery.sql

c:\myfolder\myquery.sql:

set head off
set feed off
set pagesize 0
spool c:\myfolder\myresult.csv
prompt sysdate
select to_char(sysdate, 'dd-mon-yyyy') from dual;
spool off
set head on
set feed 6
quit
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.