"export to" command

hi,
 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
ramnramAsked:
Who is Participating?
 
bretCommented:
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
go
select * from mytable
go
exit

You could also run something like this:

execute xp_cmdshell "bcp mydatabase.owner.name out myfilename -Usa -P  -c"
0
 
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"
0
 
bretCommented:
What do you mean by "Sybase 11.9"?  Sybase is the name of the company, not the product.
Are you using ASE or ASA?
0
 
bretCommented:
"select @@version" will tell you.
0
 
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
0
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.