cancel
Showing results for 
Search instead for 
Did you mean: 

How do you dump query results to a flat file

Former Member
3,796

I need to know if this is possible. I need to create a new event that will execute a query and dump the results into a flat file. This event will be run in the middle of the night without any user intervention.

What commands do I execute to achieve this?

[edit] Rookie mistake; forgot to mention that this was for a version 8 or 9 database.

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

The UNLOAD SELECT statement is your friend - I'm quite sure there are some examples and discussions on this facility (vs. OUTPUT, which won't work in procedures and events) in this forum.


Just to add w.r.t. older versions: AFAIK, both events and the UNLOAD statement have been available since v7, so you're alright with v8/v9:)

Former Member
0 Kudos

That works. Thanks a lot.

Answers (1)

Answers (1)

Former Member
0 Kudos

To dump query results to a flat file, I fire-up Sybase Central then connect to the DB. I then right-click on the connected database to run ISQL. I paste the query into ISQL and generate the result. Then select Data Export to save the result to a text file. Not sure about sa 8/9 compatibility.

VolkerBarth
Contributor

That does work for interactive users, as does using Interactive SQL with the OUTPUT statement and its various data formats - both with v8/v9, too.

Note, however, that this does not work well (err, not at all) for an automated event that has to run nightly:)