"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?
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"
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.