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 import » Data import with the INPUT statement


Importing data with the INPUT statement

You can import data into a database from a text file or from a comma delimited (CSV) file using Interactive SQL.


You must be the owner of the table, or have the following privileges:

  • INSERT privilege on the table, or the INSERT ANY TABLE system privilege
  • SELECT privilege on the table, or the SELECT ANY TABLE system privilege

Context and remarks

Because the INPUT statement is an Interactive SQL statement, you cannot use it in any compound statement (such as an IF statement) or in a stored procedure.

  1. Create a text file named newSwimwear.csv with the following values and save it to a C:\LocalTemp directory:

  2. Open Interactive SQL and connect to the SQL Anywhere sample database.

  3. Type an INPUT statement in the SQL Statements pane.

    INPUT INTO Products
    FROM C:\LocalTemp\newSwimwear.csv
    SKIP 1;

    In this statement, the name of the destination table is Products, and newSwimwear.csv is the name of the data file. The first line of the file containing column names is skipped. The file is located relative to the client computer.

  4. Execute the statement.

    If the import is successful, the Messages tab displays the amount of time it to took to import the data. If the import is unsuccessful, a message appears indicating why the import was unsuccessful.


The data is imported into the specified database.


Perform the following steps to input data from an Excel CSV file using the INPUT statement.

  1. In Excel, save the data from your Excel file into a CSV file. For example, name the file newSales.csv.

  2. In Interactive SQL, connect to a SQL Anywhere database, such as the sample database.

  3. Create a table named imported_sales and add the required columns.

  4. Execute an INPUT statement using the SKIP clause to skip over the column names that Excel places in the first line of the CSV file.

    INPUT INTO imported_sales FROM 'C:\\LocalTemp\\newSales.csv' SKIP 1;

 See also