SCOPE Element

Topic Last Modified: 2006-06-13

The Structured Query Language (SQL) SCOPE element is an optional part of the SQL FROM Predicate and is used to specify the location and depth of a search.

FROM SCOPE('[shallow|deep|hierarchical] traversal of "URL"')

A shallow traversal search examines the resources in the specified folder, but not in any of the subfolders.

Specifying deep traversal in the SCOPE element executes a search against any and all subfolders of the given folder, all the way to the bottom of the folder hierarchy.

A hierarchical traversal search is executed only against folder resources in a specified folder. A hierarchical traversal search can be used for a task such as determining the folder hierarchy of a specified folder.

"URL" is the URL of a folder in an Exchange store to be searched.

See Search Scope for more information.

Example

The following is an example of a shallow traversal search, where "URL" is a string containing the URL of the folder to be searched, and "sender" is a string containing the name of a sender.

'construct the SQL query
strQ = "SELECT ""urn:httpmail:subject"" "
strQ = strQ & "FROM scope('shallow traversal of """ & strURL & """ ')"
strQ = strQ & "WHERE ""urn:schemas:httpmail:sendername"" = '" & sender & "'"

Remarks

If the SCOPE Statement is omitted from the FROM Predicate, the search scope defaults to shallow traversal.

A deep traversal search cannot be performed against a MAPI store, such as the default public store installed by Microsoft® Exchange Server 2007 .

See Also

Other Resources

Search Scope
FROM Predicate
SELECT Statement