0

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?

1
  • Which RDBMS? Is there any data manipulation involved or is it pure reading? Commented Nov 11, 2015 at 10:04

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, you got me on the right track. i added solution in Question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.