I'm looking for a way to write resultset of a query to a file maybe analog of queryout
of MS SQL or the COPY
from PostgreSQL
When using something like
select count(*) from "table" OUTPUT TO 'results.txt' FORMAT TEXT
I'm getting
Could not execute statement. Syntax error near 'TO' on line 1
SQLCODE=-131, ODBC 3 State="42000" Line 1, column 1
When running it, as discribed in documentation like this:
select count(*) from "table";
OUTPUT TO 'results.txt' FORMAT TEXT
e.g. inside a procedure, I'm getting an error telling me that there is no result for being outputted.
Best Answer
You can specify the
OUTPUT
to a file in your SQL directly:dbisql -c "connection-string" SELECT * FROM table; OUTPUT TO 'results.txt' FORMAT TEXT
As per the Sybase documentation.