|
ODBC Driver for Microsoft Excel The RANGE feature - ODBC Driver for Microsoft Excel |
|
The RANGE feature lets you define a temporary, queryable rectangular area within an Excel worksheet and treat it as a separate table. Instead of addressing the whole sheet, you create a logical range object that maps to a specific block of cells, such as A2:D100 on a given sheet.
Use the RANGE feature when you need to work only with a subset of worksheet data—for example, when the relevant data is located in the middle of a sheet, when the sheet contains multiple unrelated tables, or when you want to isolate a stable data region from surrounding headers, notes, or intermediate calculations. By defining a range, you reduce the amount of data scanned, make queries more predictable, and simplify integration scenarios where Excel acts as a data source for applications or reporting tools.
Ranges created with this feature are temporary objects and cannot be saved in the workbook (unlike standard Excel named ranges).
You can use the following statement to create a temporary range.
CREATE RANGE <name> AS SELECT '<start>:<end>' FROM <source>
The following table describes the syntax parameters.
| Parameter | Description |
|---|---|
|
|
The name of a range to be created. |
|
|
The top-left cell of the range. |
|
|
The bottom-right cell of the range. |
|
|
The named range or existing worksheet in the workbook. It cannot be an expression or another temporary range. |
A CREATE RANGE statement cannot include clauses such as WHERE, ORDER BY, and similar SQL clauses.
The following statement creates a range named test_range that covers cells A2:D4 on the Sheet1 worksheet.
CREATE RANGE test_range AS SELECT 'A2:D4' FROM Sheet1
After a range is created, it can be queried as a regular table or view.
Use the following syntax to query a range.
SELECT * FROM test_range
Ranges created with CREATE RANGE are read-only.
SQL statements that modify data, such as INSERT, UPDATE, and DELETE, are not supported for ranges.
To change data, modify the underlying worksheet or named range in Excel and then re-create the range if required.
Use the DROP RANGE statement to delete a temporary range that is no longer required.
DROP RANGE <name>
The following table describes the syntax parameter.
| Parameter | Description |
|---|---|
|
|
The name of the existing range to delete. |