Skip to content

Instantly share code, notes, and snippets.

@ricklentz
Created January 18, 2018 15:54
Show Gist options
  • Save ricklentz/28a2981cafe06a7ed2d2710e2b92044b to your computer and use it in GitHub Desktop.
Save ricklentz/28a2981cafe06a7ed2d2710e2b92044b to your computer and use it in GitHub Desktop.
:: START BAT FILE
sqlplus username/password@host:port/service -i @run.sql
:: END BAT FILE
--START SQL FILE run.sql
SET VERIFY OFF;
SET FEEDBACK OFF
SET TERMOUT OFF
SET PAGESIZE 0
SET HEADING OFF
SET COLSEP ","
SET LINESIZE 32767
SET TRIMSPOOL ON
SPOOL \\path\to\results.csv
-- WRITE HEADER TO FILE
SELECT '"a"'
||','|| '"b"' as optional_header_row from dual;
Select * from dual;
SPOOL OFF
SET TERMOUT ON
prompt *********** Finished CSV ***********
SET HEADING ON
SET FEEDBACK ON
SET VERIFY ON;
--END SQL FILE run.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment