Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » Data import and export » Data export


Exporting query results using the UNLOAD statement

You can export query results in Interactive SQL by using the UNLOAD statement.


When unloading into a variable, no privileges are required. Otherwise, the required privileges depend on the database server -gl option, as follows:

  • If the -gl option is set to ALL, you must be the owner of the tables, or have SELECT privilege on the tables, or have the SELECT ANY TABLE system privilege.

  • If the -gl option is set to DBA, you must have the SELECT ANY TABLE system privilege.

  • If the -gl option is set to NONE, UNLOAD is not permitted.

When unloading to a file on a client computer:

  • You must have the WRITE CLIENT FILE privilege.

  • You must have write permissions on the directory where the file is located.

  • The allow_write_client_file database option must be enabled.

  • The write_client_file secure feature must be enabled.

Contexte et remarques

Use the BCP FORMAT clause to import and export files between SQL Anywhere and Adaptive Server Enterprise.

  • In the SQL Statements pane, execute an UNLOAD statement. For example:

    SELECT * FROM Employees
    TO 'C:\\ServerTemp\\Employees.csv';

    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.

    Using this form of the UNLOAD TABLE statement, the file path is relative to the database server computer.


The query results are exported to the specified location.

 See also