Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

Hi

I am using the OUTPUT TO function in ISQL and it all works fine.

When I add in the 'WITH COLUMN NAMES' the query doesn't work. I am using ASA 9, is it not possible to export column names in ASA 9?

SELECT *
FROM dba.table1
ORDER BY table1.part_number ASC;
OUTPUT TO 'c:\\filename.csv'
    FORMAT ASCII
    QUOTE '"'
    WITH COLUMN NAMES

If not is there a workaround for exporting the column names?

asked 21 Jun '17, 07:04

Jongee's gravatar image

Jongee
217171722
accept rate: 0%


The WITH COLUMN NAMES clause was added to the OUTPUT command with v12, so it's clearly not available with v9.

A workaround is to use two queries:

  • A first query to export the column names, such as
    select list(string('"', cname, '"') order by colno asc)
    from sys.syscolumns where creator = 'dba' and tname = 'table1';
    output to 'c:\\filename.csv' format ascii quote '"';
  • Your original query as second one - and OUTPUT used with the APPEND option
    select * from dba.table1
    order by table1.part_number asc;
    output to 'c:\\filename.csv' format ascii quote '"' append;

(Have not tested the queries lacking v9, but you should get the point...)

permanent link

answered 21 Jun '17, 07:38

Volker%20Barth's gravatar image

Volker Barth
40.5k365556827
accept rate: 34%

edited 21 Jun '17, 07:42

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×28

question asked: 21 Jun '17, 07:04

question was seen: 3,964 times

last updated: 21 Jun '17, 07:42