"export to" command

Posted on 2006-03-23
Last Modified: 2010-10-05
 i want to export data from a table to a flat file. I want to do this operation from my stored procedure after doing some manipulations with the table. I know there is a comman "export to" in isql. i am using sybase 11.9. i want syntax for this with example
Question by:ramnram
    LVL 10

    Accepted Solution

    ISQL itself does not have an "export to" command.  

    Sybase Adaptive Server Anywhere does have such a command, though - if you
    are using ISQL against ASA, you can execute that command - but it is ASA doing
    it, not ISQL

    select * from employee where 1=0;
    output to 'c:\test.xls' format excel;

    You can, however, direct output to a file with isql using the -o parameter.

    isql -Usa -P -o myfilename
    use mydatabase
    select * from mytable

    You could also run something like this:

    execute xp_cmdshell "bcp out myfilename -Usa -P  -c"

    Author Comment

    This is not working for me.I am using Sybase 11.9.

    Error i am getting is:
    Line 2:
    Incorrect syntax near the keyword 'to'.

    Also tell me "where should i give this command"
    LVL 10

    Expert Comment

    What do you mean by "Sybase 11.9"?  Sybase is the name of the company, not the product.
    Are you using ASE or ASA?
    LVL 10

    Expert Comment

    "select @@version" will tell you.
    LVL 14

    Expert Comment

    11.9 is for sure ASE not ASA

    You may try the last solution that bret mentioned:

    execute xp_cmdshell "bcp out myfilename -Usa -P  -c"

    But be aware, that output file will be created on server machine, not on client.

    By redirecting isql output you will get some formating stuff in your output file, so it will need some polishing, but this way you get output file on client machine

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    After several days of searching and hunting for limited documentation, I wanted to share this guide to hopefully save someone the hassle of trying to figure this out on their own. I have tested this on Xendesktop 7.1 and PS 4.5 running simultaneous…
    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now