Reputation: 21
Is it possible to export the results of a query (a select statement with multiple joins) to an Excel spreadsheet without having to manually export the data, so the script runs the query and also executes the transfer to Excel?
Upvotes: 0
Views: 87
Reputation: 169
You can use this code in SQL*Plus and Oracle SQL Developer.
Create a .sql file. (Create a text file and change the extension to .sql)
Put the following code in the file:
set heading off
spool excel_1.xls
select
first_name||chr(9)||last_name
from
employees;
spool off
Since I have made use of employees table from HR schema, connect hr schema. Execute the script file
@<filename>.sql
you can use any number of columns but each should be separated as shown in above example.
Upvotes: 1