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

SQL Anywhere 11.0.0 » SQL Anywhere Server - Programming » SQL Anywhere Data Access APIs » SQL Anywhere OLE DB and ADO APIs


Setting up a Microsoft Linked Server using OLE DB

A Microsoft Linked Server can be created that uses the SQL Anywhere OLE DB provider to obtain access to a SQL Anywhere database. SQL queries can be issued using either Microsoft's 4-part table referencing syntax or Microsoft's OPENQUERY SQL function. An example of the 4-part syntax follows.


In this example, SADATABASE is the name of the Linked Server, GROUPO is the table owner in the SQL Anywhere database, and Customers is the table name in the SQL Anywhere database. The catalog name is omitted (as indicated by two consecutive dots) since catalog names are not a feature of SQL Anywhere databases.

The other form uses Microsoft's OPENQUERY function.


In the OPENQUERY syntax, the second SELECT statement ( 'SELECT * FROM Customers' ) is passed to the SQL Anywhere server for execution.

To set up a Linked Server that uses the SQL Anywhere OLE DB provider, a few steps must be followed.

To set up a Linked Server

  1. Fill in the General page.

    The Linked Server field on the General page should contain a Linked Server name (like SADATABASE used above). The Other Data Source option should be selected, and SQL Anywhere OLE DB Provider should be selected from the list. The Product Name field should contain an ODBC data source name (for example, SQL Anywhere 11 Demo). The Provider String field can contain additional connection parameters such as user ID and password (for example, uid=DBA;pwd=sql). Other fields, such as Data Source, on the General page should be left empty.

  2. Select the Allow Inprocess provider option.

    The technique for doing this varies with different versions of Microsoft SQL Server. In SQL Server 2000, there is a Provider Options button that takes you to the page where you can select this option. In SQL Server 2005, there is a global Allow Inprocess checkbox when you right-click the SAOLEDB provider in the Linked Servers/Providers tree view and choose Properties. If the InProcess option is not selected, queries fail.

  3. Select the RPC and RPC Out options.

    The technique for doing this varies with different versions of Microsoft SQL Server. In SQL Server 2000, there are two checkboxes that must be selected for these two options. These check boxes are found on the Server Options page. In SQL Server 2005, the options are True/False settings. Make sure that they are set True. The Remote Procedure Call (RPC) options must be selected if you want to execute stored procedure/function calls in a SQL Anywhere database and pass parameters in and out successfully.