Special Queries
Extended WQL supports queries that are specific to SMS needs. The following table describes the additional queries that are supported.
Query type | Search set |
---|---|
Array property | Particular values in an array property. |
Base class | Property values that exist in a base class. |
Prototype | A class definition rather than class data. |
Collection-limiting | Data that is specific to a particular collection. |
Array Property Queries
Due to the nature of array properties, including them in an Extended WQL query can be somewhat complex. For example, consider the SMS_R_System class that includes the IPAddresses property. The IPAddresses property is an array that contains one or more individual addresses. To query for computers with IP addresses, you can specify one of the following two queries:
SELECT * FROM SMS_R_System WHERE IPAddresses = "2.2.2.2" SELECT * FROM SMS_R_System WHERE IPAddresses IN ("1.1.1.1", "2.2.2.2")
Base Class Queries
Extended WQL queries on a base class return instances from all of the subclasses. For abstract base class queries, the instances that are returned are always instances of the derived classes. For example, the following query returns instances from classes such as SMS_SCI_Component and SMS_SCI_Address, which inherit properties from SMS_SiteControlItem.
SELECT * FROM SMS_SiteControlItem WHERE Sitecode="ABC"
Prototype Queries
Extended WQL allows you to request that the result set contain a definition of the class to be returned rather than the actual instances of the class. There are two possible results from this type of query. For most cases, a prototype query returns a class object that contains the definition. If the query is a JOIN with multiple classes in the SELECT statement, the prototype query returns an instance of the __Generic class.
Although prototype queries are most useful in processing the results of JOIN operations, they are supported for all queries. To request a class definition as the result set, set the lFlags parameter in IWbemServices::ExecQuery or IWbemServices::ExecQueryAsync to WBEM_FLAG_PROTOTYPE.
Collection-limiting Queries
An SMS collection is a grouping of resources such as computers and users. Extended WQL supports queries against particular collections. There are two approaches that you can use to limit a query to a particular collection:
- Set the LimitToCollectionIDs context value to the required CollectionID value. This context value is made available through the IWbemContext pointer in the IWbemServices::ExecQuery method to the name of the collection.
- Specify an inner JOIN operation using the SMS_CollectionMember-derived classes in the query passed to ExecQuery.
The second approach is slower, but it is the only possible approach if you use an application that uses the WMI ODBC Adapter.