You can export query results in Interactive SQL using the Data menu, or either of the OUTPUT or UNLOAD statements.
Prerequisites
None.
Context and remarks
You can combine the APPEND and VERBOSE clauses to append both results and messages to an existing file.
For example, type OUTPUT TO 'filename' APPEND VERBOSE.
The OUTPUT statement with its clauses APPEND and VERBOSE are equivalent to the >#, >>#, >&, and >>& operators of earlier versions of Interactive SQL. You can still use these operators to redirect data, but the new Interactive SQL statements allow for more precise output and easier to read code.
Use the BCP FORMAT clause to import and export files between SQL Anywhere and Adaptive Server Enterprise.
Enter your query in the SQL Statements pane of Interactive SQL.
Click SQL » Execute.
Click Data » Export.
Specify a location for the results and click Next.
For text, HTML, and XML files, type a file name in the File Name field and click Export.
For an ODBC database:
Select a database and click Next.
Select a location to save the data and click Export.
Click Close.
Use the BCP FORMAT clause to import and export files between SQL Anywhere and Adaptive Server Enterprise.
Enter your query in the SQL Statements pane of Interactive SQL.
At the end of the query, type OUTPUT TO 'filename'.
For example, to export the entire Employees table to the file employees.txt, enter the following query:
SELECT * FROM Employees; OUTPUT TO 'employees.txt'; |
To export query results and append the results to another file, use the APPEND clause.
SELECT * FROM Employees; OUTPUT TO 'employees.txt' APPEND; |
To export query results and include messages, use the VERBOSE clause.
SELECT * FROM Employees; OUTPUT TO 'employees.txt' VERBOSE; |
Click SQL » Execute.
If the export is successful, the Messages tab displays the amount of time it to took to export the query result set, the file name and path of the exported data, and the number of rows written. If the export is unsuccessful, a message appears indicating that the export was unsuccessful.
Use the BCP FORMAT clause to import and export files between SQL Anywhere and Adaptive Server Enterprise.
In the SQL Statements pane, enter the UNLOAD statement.
For example:
UNLOAD SELECT * FROM Employees TO 'employee_data.csv'; |
Click SQL » Execute.
If the export is successful, the Messages tab displays the amount of time it to took to export the query result set, the file name and path of the exported data, and the number of rows written. If the export is unsuccessful, a message appears indicating that the export was unsuccessful.
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |