2

i have this kind of script that i want to spool the final output to a csv file. can you please help?

with first_sub as
select etc
,
second_sub as
select etc

select first_column from first_sub* first_column from second_sub etc.

...................................... ..basically, i have 2 or more sub queries that i do maths on in my 'final query' what i need is to be able to spool the output as a csv.

sorry but im not able to post any specific code

ok, to clarify, i CAN ALREADY spool a 'Simple' query i.e `select *from employees'

what i have is like this

    with sub_1 as 
    select * from employees
    ,
    sub_2 as 
    select * from other_employees

select something from sub1 * something_else from sub_2

The last bit is what i want to take out to a .csv file please

3
  • 1
    Welcome to SO. Please first post a correct query, then we can handle the csv question. Also, please post the type of the fields you need to spool ( do you have dates, numbers, ...?) Commented Oct 24, 2016 at 9:36
  • 2
    Possible duplicate of How do I spool to a CSV formatted file using SQLPLUS? Commented Oct 24, 2016 at 9:39
  • It always helps to share correct query and as much information as possible ... Commented Oct 24, 2016 at 10:12

1 Answer 1

2

-- SQL developer You can use /*csv*/ hint in SQL developer. As @Aleksej suggested, you can see the linked thread for further options.

select /*csv*/ * from employees; 

--SQL Plus

set feedback off
set heading on
set underline off
set colsep ','

spool 'mytab.csv'
select * from tab;
spool off
Sign up to request clarification or add additional context in comments.

1 Comment

that SQLPlus code sample will also run in SQL Developer, sans the set underline

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.