Sql Property

Applies To

PivotCache object, QueryTable object.

Description

Returns or sets the SQL query string used with the specified ODBC data source. Read/write String.

Remarks

This property supports the full ODBC Data Manipulation Language (DML) grammar, including wild card characters, and stored procedures that return data. This property doesn't support Data Definition Language (DDL) statements.

Example

This example changes the SQL query string for query table one and then refreshes the query table.

With Worksheets(1).QueryTables(1)
    .Sql = "select 96Sales.totals from 96Sales where profit < 5"
    .Refresh
End With