In Interactive SQL, you can export data from your database to a CSV file by using the OUTPUT statement.
You must have the SELECT ANY TABLE system privilege or SELECT privilege on the table.
In Interactive SQL, connect to a SQL Anywhere database.
Execute an OUTPUT statement with the clauses FORMAT TEXT, QUOTE '"', and WITH COLUMN NAMES to create a comma-delimited format with the column names in the first line of the file. String values are enclosed with quotation marks. For example:
SELECT * FROM SalesOrders; OUTPUT TO 'C:\\LocalTemp\\newSales.csv' FORMAT TEXT QUOTE '"' WITH COLUMN NAMES;
The following example exports the data from the Employees table in the SQL Anywhere sample database to Employees.csv in the C:\LocalTemp directory.
SELECT * FROM Employees; OUTPUT TO C:\LocalTemp\Employees.csv FORMAT TEXT;
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|