Skip to Content

export data using the output command from interactive sql

It is requested to export data from ASE in a csv file having all the data quoted. In Interactive SQL GUI we can use this

OUTPUT TO 'C:\tmp\data.csv' FORMAT ASCII

DELIMITED BY ',' QUOTE '''' ALL ENCODING cp1253

GO

and it returns the desired result. However we cannot create a script executed from command line that produces this file, because the GUI dbisql cannot take any arguments in order to connect to an ASE instance and execute an SQL file and the command line isql cannot accept the output command. I think we cannot achieve this using only the ASE client tools

A supposed solution could be to create a string for each row and export it using bcp or even isql. I would prefer to avoid such an approach.

Thank you in advance

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Nov 12, 2015 at 05:29 PM

    Both bcp and isql can create rows where columns are separated by tab.

    This typically suffices for exporting to excel etc.

    You can also use some other character like '|" pipe symbol or "~" tilde etc. to separate columns. When you import in excel you can use that as a column separator.

    For bcp use character mode output, tab is default column separator.

    For isql space is the default column separator

    If you want to use different column separator (e.g. "|" ) then

    for bcp use -c -t '|' option

    for isql use -s '|' option

    Output of isql and bcp can be directed into a file. Similar to what you describe above.

    You can also easily script wrappers to accept server, database and table/view names to run for a specific purpose.

    HTH

    Avinash

    Add a comment
    10|10000 characters needed characters exceeded

    • Cool.

      I have depended mostly on isql for DBA work and frankly had not paid enough attention to dbisql so far.

      So it was a refreshing segway to learn about it 😊

      Thanks Kimon for raising the expectation bar !

      And thanks to Simon for providing inputs on what really works.

      Thanks and regards

      Avinash

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.