Use the Data menu, the OUTPUT statement, or the UNLOAD statement to export queries (including queries on views) to a file.
Use the BCP FORMAT clause to import and export files between SQL Anywhere and Adaptive Server Enterprise. For more information, see Adaptive Server Enterprise compatibility.
Enter your query in the SQL Statements pane of Interactive SQL.
Choose SQL » Execute.
Choose 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.
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; |
Choose 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.
For more information about exporting query results using the OUTPUT statement, see OUTPUT statement [Interactive SQL].
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.
For more information about APPEND and VERBOSE, see OUTPUT statement [Interactive SQL].
In the SQL Statements pane, enter the UNLOAD statement. For example,
UNLOAD SELECT * FROM Employees TO 'employee_data.csv'; |
Choose 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 © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |