Home » SQL & PL/SQL » SQL & PL/SQL » Export to CSV issue
Export to CSV issue [message #192451] Tue, 12 September 2006 08:02 Go to next message
Messages: 1
Registered: September 2006
Location: Leicester, UK
Junior Member

I'm having a problem with a little script I am writing in SQLPlus. I have a fair bit of experience with MS SQL, but am having an issue with converting to Oracle!

Basically, I need to extract data using a sql script into a CSV File. To do this, I have the following script:

set echo off heading off feedback off
spool c:\localdata\customer_data_out.csv
set newpage 0
set pagesize 0
set linesize 1000
set trimspool on
set space 0
SELECT DISTINCT rtrim(custrec.custNo,) as CustNum,
FROM custrec

I run this from the DOS command line using a scheduler.

My problem is that the first data field is padded, so the output I get in the csv file is like this:

(The _'s are actually spaces, but I can't seem to post extraneous spaces!)

Whereas I need to to be like this:


without the spaces

Also, the outputted csv appears to have an extra line break at the end of the file.

Any ideas?

Many thanks
Re: Export to CSV issue [message #192454 is a reply to message #192451] Tue, 12 September 2006 08:13 Go to previous message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
better approach.

Previous Topic: query a table
Next Topic: Truncate trailing spaces on select
Goto Forum:

Current Time: Tue Oct 25 11:13:32 CDT 2016

Total time taken to generate the page: 0.13915 seconds