Total Pageviews

November 25, 2015

11/25/2015 11:46:00 PM

Generating Of Delimited Output Using SQL

In order to generate a delimited file output, you need to concatenate columns using the desired delimiter i.e. comma:

Example:

select empno|| ‘,’||ename||’&’||mgr from X;

Other option is using:

SQL> set colsep ‘,’
SQL> spool c:\testexcel.csv
SQL> select * from emp;

Change some of the default SQL*Plus parameters, that will be garbage for Excel:

feedback=off
newpage=none
termout=off
header=off

If some columns are empty, be aware to include the delimiter, too:

nvl(to_char(col2),’,')
 
Related Posts Plugin for WordPress, Blogger...