How to save SQL query output in excel format?

Toad makes it easy to export the output of executed sqlplus queries to excel -xls using toad. Here’s how to do this on the sql prompt. To save the output, you will need to use text formatting options as well as a spool file name. “save SQL query output in excel format”.

Save SQL query output in excel

Using the below script you can save the Oracle SQL query output directly into excel format.

SET PAGESIZE 40000
SET FEEDBACK OFF
SET MARKUP HTML ON
SET NUM 24
SPOOL /u01/spool_file_name.xls
SELECT COUNT * FROM emp;
SPOOL OFF
SET MARKUP HTML OFF
SPOOL OFF

The spool file is generated inside /u01 directory, which is in .xls format. So, this is the best way to generate a spool file into excel format.

You Must Read: RMAN Output in Log

1 thought on “How to save SQL query output in excel format?”

Leave a Comment