Share via


The SELECT Statement

The SELECT Statement

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can use a SELECT Statement to return the values of properties for items in a particular folder, or folders, within a store. Each SELECT Statement is executed within the context of an OLE DB session (Microsoft® ActiveX® Data Objects (ADO) connection) that implicitly defines the public store or mailbox store and the folder tree being searched. The SELECT Statement has the following syntax:

SELECT select-list | *
FROM SCOPE(resource-list)
[WHERE search-condition]
[order-by-clause]

To request specific properties, you enclose each property name in quotation marks and separate each property name with a comma. For example:

SELECT "DAV:href", "DAV:displayname" ...

Note that calculated properties are Non-Searchable Properties and should not be used in the SELECT Statement.

The Search Scope to execute is the combination of a folder URL and a traversal depth. For example:

'shallow traversal of "https://server/vroot/folder1"'
'shallow traversal of "file://./backofficestorage/domain.tld/pub2/f1"'

When you execute a Structured Query Language (SQL) SELECT Statement using the Exchange OLE DB (ExOLEDB) provider, you can use a URL relative to the top-level public folder. A relative URL can be used as well, as in the following example:

'shallow traversal of "/folder1/"'
'deep traversal of "/folder1/folder2/"'

A FROM Predicate does not require an explicit SCOPE Element, in which case a shallow traversal is assumed. For example:

FROM "https://server/vroot/folder1"

If a SCOPE Element is specified in the SQL query statement but a depth is not, the Exchange store query processor assumes a deep traversal, as in the following example:

FROM SCOPE("https://server/vroot/folder1") (deep traversal here)

Tokens, which are properties in a select list or values in a WHERE Clause, must be delimited by single quotations marks. A token can contain only alphabetic characters unless it is also enclosed in double quotation marks. In the following SQL WHERE Clause, a full-text search is requested. In the following request string, "this" and "that" are tokens:

WHERE CONTAINS (' "this" AND "that" ')

This clause does not work:

WHERE CONTAINS ('10 dollars')

To fix the clause, surround the token with double quotation marks within the single quotation marks:

WHERE CONTAINS ('"10 dollars"')

Use of the CONTAINS Predicate is restricted to properties that are marked for full-text indexing, and only if full-text searching has been enabled for that particular store.

The Exchange store does not support deep traversals in the public store designated for MAPI clients, such as Microsoft Outlook®. If either an explicit or implicit deep traversal is requested, the Exchange store query processor returns an error.

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.