"export to" command

 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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 mydatabase.owner.name out myfilename -Usa -P  -c"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ramnramAuthor Commented:
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"
What do you mean by "Sybase 11.9"?  Sybase is the name of the company, not the product.
Are you using ASE or ASA?
"select @@version" will tell you.
Jan FranekCommented:
11.9 is for sure ASE not ASA

You may try the last solution that bret mentioned:

execute xp_cmdshell "bcp mydatabase.owner.name 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Sybase Database

From novice to tech pro — start learning today.