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

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

FORWARD TO statement

Sends native syntax SQL statements to a remote server.

  • Forward a single statement
    FORWARD TO server-name sql-statement
  • Enter passthrough mode
    FORWARD TO [ server-name ]
  • Exit passthrough mode
  • server-name

    The name of the remote server.

  • sql-statement

    A command in the native SQL syntax of the remote server. The command or group of commands is enclosed in braces ({}) or single quotes.


The FORWARD TO statement enables users to specify the server to which a passthrough connection is required. The statement can be used in two ways:

  • Syntax for forwarding a single statement

    Send a single statement to a remote server.

  • Syntax for passthrough mode

    Place the database server into passthrough mode for sending a series of statements to a remote server. All subsequent statements are passed directly to the remote server. To turn passthrough mode off, execute FORWARD TO without a server-name specification.

    If you encounter an error from the remote server while in passthrough mode, you must still execute a FORWARD TO statement to turn passthrough off.

    Proxy Tables: The user must login to connect to a remote server using this syntax. If the FORWARD TO statement appears in a procedure owned by a different owner, or if the statement appears in an event (or any procedure called by an event), no authentication has taken place and hence there is no password to be forwarded. The only way that proxy table usage can work in this scenario is to define an EXTERNLOGIN.

When establishing a connection to server-name on behalf of the user, the database server uses one of the following:

  • A remote login alias set using CREATE EXTERNLOGIN

  • If a remote login alias is not set up, the name and password used to communicate with the database server

If the connection cannot be made to the server specified, the reason is contained in a message returned to the user.

After statements are passed to the requested server, any results are converted into a form that can be recognized by the client program.

Note The FORWARD TO statement is a server directive and cannot be used in stored procedures, triggers, events, or batches. However, the dbo.sp_forward_to_remote_server() system procedure can be used in stored procedures, triggers, events or batches.


Side effects

The remote connection is set to AUTOCOMMIT (unchained) mode for the duration of the FORWARD TO session. Any work that was pending before the FORWARD TO statement is automatically committed.

  • ANSI/ISO SQL Standard

    Not in the standard.


The following example sends a SQL statement to the remote server RemoteASE:

FORWARD TO RemoteASE { SELECT * FROM titles };

The following example shows a passthrough session with the remote server aseprod:

FORWARD TO aseprod;
    SELECT * FROM titles;
    SELECT * FROM authors;