Run SQL script files in Interactive SQL

You can execute SQL script files in any of the following ways:

  • You can run a SQL script file without loading it into the SQL Statements pane.

     Run a SQL script file immediately
    1. In Interactive SQL, click File » Run Script.

    2. Locate the file, and click Open.

      The contents of the specified file are run immediately. A Status window appears to show the execution progress.

      The Run Script menu item is the equivalent of a READ statement. See below for an example of the READ statement.

  • You can also run a SQL script file without loading it into the SQL Statements pane with the Interactive SQL READ statement.

     Run a SQL script file using the Interactive SQL READ statement
    • In the SQL Statements pane, type the following statement:

      READ 'c:\\filename.sql';

      In this statement, c:\filename.sql is the path, name, and extension of the file. Single quotation marks (as shown) are required only if the path contains spaces.

  • You can supply a SQL script file as a command line argument for Interactive SQL.

     Run a SQL script file in batch mode (command line)
    • Run the dbisql utility and supply a SQL script file as a command line argument.

      For example, the following command runs the SQL script file myscript.sql against the SQL Anywhere sample database.

      dbisql -c "DSN=SQL Anywhere 12 Demo" myscript.sql
  • You can load a SQL script file into the SQL Statements pane and execute it directly from there.

     Load a SQL script from a file into the SQL Statements pane
    1. Click File » Open.

    2. Locate the file, and click Open.

      The statements are displayed in the SQL Statements pane where you read, edit, or execute them.

    On Windows platforms you can make Interactive SQL the default editor for .sql script files. This lets you double-click the file so that its contents appears in the SQL Statements pane of Interactive SQL.

  • You can also load a SQL script file into the SQL Statements pane from your favorites.

 See also