SQL Oracle - How to save the query output with spool on a text file?

Adam Brave picture Adam Brave · Mar 5, 2015 · Viewed 25.5k times · Source

I'm using spool to save the output of my query into a text file but what is actually doing is save the sql commands into the file.

I have:

SPOOL D:\sqltestes\sql_test.txt
SELECT max(column1) from my_table;
SPOOL OFF;

And this, is writting on the text file the "SELECT max(column1) from my_table;" and not the result of the query... Why?

Help please!

Answer

Atilla Ozgur picture Atilla Ozgur · Mar 10, 2015

I assume you are using Sql Developer or Toad. I already answered this one. There is a difference between Run Statement and Run Script. Try Run Script.