How to output data from iSQL to csv file _with_ headings?

Oliver Jakoubek picture Oliver Jakoubek · Dec 4, 2010 · Viewed 79.6k times · Source

I'm trying to query a Sybase ASA 8 database with the iSQL client and export the query results to a text file in CSV format. However the column headings are not exported to the file. There is no special option to specify that, neither in the iSQL settings nor in the OUTPUT statement.

The query and output statement looks like this:

SELECT * FROM SomeTable;
OUTPUT TO 'C:\temp\sometable.csv' FORMAT ASCII DELIMITED BY ';' QUOTE ''

The result is a file like

1;Miller;Steve;1980-06-28
2;Jones;Martha;1965-11-02
3;Waters;Richard;1979-10-15

while I'd like to have

ID;LASTNAME;FIRSTNAME;DOB
1;Miller;Steve;1980-06-28
2;Jones;Martha;1965-11-02
3;Waters;Richard;1979-10-15

Any hints?

Answer

pascal picture pascal · Jan 28, 2011

I would have suggested to start with another statement:

SELECT 'ID;LASTNAME;FIRSTNAME;DOB' FROM dummy;
OUTPUT TO 'C:\\temp\\sometable.csv' FORMAT ASCII DELIMITED BY ';' QUOTE '';

and add the APPEND option on your query... but I can't get APPEND to work (but I'm using a ASA 11 engine).