Quantcast
Channel: Toad for Oracle
Viewing all articles
Browse latest Browse all 4009

Forum Post: RE: How do I add the colum'names in exporting SQL to text using Run as script

$
0
0
Evening All, Welcome to Toad mbellemax, I'm sure you'll enjoy your time here. As Gene mentioned, you can export to a csv file after running the query with the F9 option. When the results are displayed in Toad, right click on the results grid, choose 'export resultset' and in the dialogue that appears, choose to export as a csv file, or any other delimited file type, and there's an option to export with column headers. However, you do need to use F9 to execute the query, not F5 which is the execute as a script option. You won't need all the set commands either, nor the spool commands, just the query by itself. But let's say that you absolutely must use F5. In this case you would leave all the set commands and the spool commands as you have them, but you would need to adjust the query as follows: -- PRINT THE CSV HEADING FIRST. Print 'CLI,AGE,NCP,DEV' -- NOW RUN THE QUERY. Select cli || ',' || age || ',' || ncp || ',' || dev as csv from prod.bkhis order by cli asc; I'm not at a computer at the moment, I'm in the bath (don't ask!), so the above is untested. I'm not sure why you had the group by clause in your query because you are not aggregating anything, so I removed it. Dbms_output.put line is a pl/sql procedure that prints text during out AFTER THE QUERY HAS FINISHED. So your headings would, had you got the syntax correct, be printed after the results, which is probably not what you expect. You would use it as follows: Set serverout on size unlimited Begin Dbms_output.put_line('Hello World!'); End; / Then run that with F5. Hth. Cheers, Norm. [TeamT]

Viewing all articles
Browse latest Browse all 4009


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>