Export to CSV issue [message #192451] |
Tue, 12 September 2006 08:02 |
Billy69
Messages: 1 Registered: September 2006 Location: Leicester, UK
|
Junior Member |
|
|
Hi,
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,
',',
custrec.DOB
FROM custrec
ORDER BY CustNum ASC
/
exit
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:
012345666__________,01-NOV-88
(The _'s are actually spaces, but I can't seem to post extraneous spaces!)
Whereas I need to to be like this:
012345666,01-NOV-88
without the spaces
Also, the outputted csv appears to have an extra line break at the end of the file.
Any ideas?
Many thanks
David
|
|
|
|