in oracle 10g how to convert the output of ' select * from emp' to excel file

in oracle 10g how to convert  the output of ' select * from emp' to excel file
priya saxenaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Are you using sqlplus or some graphical development environment? On which OS?
0
Gerwin Jansen, EE MVETopic Advisor Commented:
If you are using sqlplus, you can do this to create a csv file that can be opened by Excel:

spool file.csv
select column1 || ',' ||  column2 ',' || column3
from emp;
spool off

You need to specify every column you want in the above select statement. If you have columns that contain spaces, you could add "" - like this:
(column2 is the one with spaces)

select column1 || ',"' ||  column2 '",' || column3

You can add some settings after the first spool command to get nice output:

set headsep off
set echo off
set feedback off
set linesize 1000
set pagesize 0
set trimspool on
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve WalesSenior Database AdministratorCommented:
I normally find that for a simple query that it's easier to open Excel and import directly from MS Query.   You launch Excel, Select Data / Import External Data and then you can connect to an ODBC Data Source via the wizard that launches and it will guide you through.

Alternatively you can also use a tool Oracle SQL Developer (free)  or a paid tool like PL/SQL Developer to run the query and then export the result grid directly to Excel.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MikeOM_DBACommented:
When using SQL*Plus, you can create XML files which are easily imported into Excel.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
Gerwin Jansen, EE MVETopic Advisor Commented:
There are answers given here, I suggest as solution https:#a40459385 with assist for https:#40459439 and https:#a40462760
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.