SQL.EXEC.QUERY

Macro Sheets Only

Sends a query to a data source using an existing connection. If this function is not available, you must install the Microsoft ODBC add-in (XLODBC.XLA).

Syntax

SQL.EXEC.QUERY(connection_num, query_text)

Connection_num is the unique connection ID of the data source you want to query.

Query_text is the SQL language query that is to be executed on the data source. The query must follow the SQL syntax guidelines in the appendix of the Microsoft Excel ODBC Developers Guide.

Remarks

Example

SQL.EXEC.QUERY(conn1, "SELECT Custmr_ID, Due_Date FROM Orders WHERE Order_Amt > 100") executes a SQL query from a SQL table named "Orders"

Related Functions

SQL.OPEN Establishes a connection with a data source

SQL.BIND Specifies storage for a result column

SQL.RETRIEVE.TO.FILE Retrieves query results and places them in a file

SQL.RETRIEVE Retrieves query results

SQL.GET.SCHEMA Gets information about a connected data source.

SQL.CLOSE Closes a data source connection

SQL.ERROR Returns detailed error information

List of Command-Equivalent Functions