Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Server

Microsoft Systems Management Server 2003 : Queries (part 1) - Query Elements

2/15/2013 6:02:47 PM

As you know, the premise behind any database query is the return of information based on a set of criteria. In other words, you define what information you’re trying to obtain in the form of a query statement. The query engine then searches the database for entries that match your criteria. The query result then displays the data that matched your criteria.

The same is true for SMS queries. To define a simple SMS query, you would specify an SMS object to search on, one or more attributes of the object, an operator of some kind, and a value. For example, suppose you’re querying for computers with processors greater than 700 MHz. In this case, computer is an object, processor is an attribute of the object, greater than is the relational operator, and 700 MHz is the value.

You can use SMS queries for a variety of purposes. Generally, we think of queries as a means of reporting on data in the database. Indeed, we might use SMS queries to find all the computers that meet a certain memory, disk space, and platform requirement before sending out a package to them. And as we’ve seen, queries are particularly useful in defining collection memberships. Collections whose members are based on the results of a query can be updated periodically to keep them current. Any programs advertised to a collection are automatically made available to the collection’s members. As the query runs and updates the collection, new members automatically receive any advertisements that targeted the collection, and deleted members no longer receive the advertisements.

You can generate SMS queries a couple of ways. The easiest way to create and run a query—and the easiest method to learn—is using SMS Query Builder, which is built into the SMS Administrator Console. This interface provides you with a point-and-click method for building your query. You could also write the query statements yourself; however, this method entails learning a query language—specifically, WMI Query Language (WQL).

Unlike other SQL Server databases, SMS relies on the Windows Management Instrumentation (WMI) layer to expose its database information to the SMS Administrator Console and other tools. Therefore, you can’t use regular SQL queries or commands to extract data from the SMS database. Instead, you’re specifying WMI object classes and attributes that the query uses to access and search the SMS database. For example, most of the queries that you create and use for collection membership will likely be based on the SMS_R_System discovery class, which contains discovery record properties such as IP Address, OperatingSystemNameandVersion, and Name, and on the SMS_G_System set of inventory classes, such as SMS_G_System_Processor, which includes processor data such as Name and ResourceId, and SMS_G_System_x86_PC_Memory, which includes memory data such as TotalPhysicalMemory.

More Info

For more information about SMS object classes and properties, see the Microsoft Systems Management Server 2003 Software Development Kit (SDK), available through the Microsoft SMS Web site (http://www.microsoft.com/smserver) and through the Microsoft Developer Network (MSDN) program (http://msdn.microsoft.com).


Consequently, it’s not recommended that you access the SMS database using regular SQL queries. What you need is a tool that can connect to WMI to access the SMS Provider and collect the information you require. You can use any third-party utility that’s WMI Open Database Connectivity (ODBC)–compliant for this purpose. For example, you could use a reporting tool such as Microsoft Excel 2002 or Microsoft Access 2002 with the WMI ODBC drivers to report on SMS data. For more information about how to access a SQL database using a third-party tool, refer to the documentation for that tool.

SMS 2003 loads 21 predefined queries, as shown in Figure 1. As you can see, these predefined queries are fairly general in scope and are meant to be more globally oriented, perhaps as the target of an advertisement. However, you can certainly create your own queries—for example, to assist with certain management tasks, including populating and updating collections and viewing client status messages.

Figure 1. Predefined queries in SMS 2003.

Query Elements

Before we review the steps for creating a query, let’s take a look at the individual elements that make up a query. The relationship between these elements is illustrated in Figure 2. As mentioned, you begin your query definition by selecting a WMI object class to query on. However, when you use the SMS Query Builder, these objects use friendly names that make it easier to select the correct object and attribute. We’ll gear our discussion toward these friendly object names.

Figure 2. The relationship between objects, their attribute classes, and the attributes of each class.

SMS provides several object types for generating queries. An object type has specific attribute classes that describe it. For example, the System Resource object type is defined by its memory, environment, logical disk, processor, and network attribute classes, among other elements. An attribute class is essentially a category of attributes and contains an attribute list. For example, the System Resource attribute class includes the IP Addresses, IP Subnets, NetBIOS Name, Operating System Name and Version, and SMS Assigned Sites attributes.

Table 1 lists the more frequently used object types, some of their attribute classes, and a short list of attributes.

Table 1. SMS objects and some of their attribute classes and attributes
Object TypeAttribute ClassesAttributes
AdvertisementAdvertisementAdvertisement ID, Advertisement Name, Collection ID, Package ID, Program Name
PackagePackageDescription, Manufacturer, Name, Package ID, Priority
ProgramProgramCommand Line, Comment, Disk Space Required, Package ID, Working Directory
SiteSiteBuild Number, Install Directory, Server Name, Site Code, Site Name
Software Metering RuleSoftware Metering RuleEnabled, File Name, File Version, Language, Rule Name, Site Code
Software Product ComplianceSoftware Product ComplianceCategory, Product Company, Product Name, Product Version, Type
System ResourceAdd Or Remove ProgramsDisplay Name, Product ID, Publisher, Version
 Collected FileCollection Date, File Name, File Path
 Logical DiskFile System. Free Space, Volume Name
 MemoryTotal Pagefile Space, Total Physical Memory, Total Virtual Memory
 Network AdapterAdapter Type, MAC Address, Manufacturer
 Operating SystemBuild Number, Manufacturer, Version
 ProcessorFamily, Manufacturer, Max Clock Speed
 System ResourceIP Addresses, NetBIOS Name, Operating System Name And Version
User Group ResourceUser Group ResourceName, Resource ID, SMS Assigned Sites, User Group Name, Microsoft Windows NT Domain
User ResourceUser ResourceFull User Name, Resource ID, SMS Assigned Sites, User Name, Windows NT Domain

The criterion type defines what you’re comparing the attribute with. The six criterion types are listed in Table 2.

Table 2. Criterion types
TypeDescription
Null ValueUsed when the attribute value may or may not be null
Simple ValueConstant value against which the attribute is compared
Prompted ValuePrompts you to enter a value before the query is evaluated
Attribute ReferenceLets you compare the query attribute to another attribute that you identify
Subselected ValuesLets you compare the query attribute to the results of another query that you specify
List Of ValuesList of constant values against which the attribute is compared

Along with the criterion type, you will select a relational operator and supply a value to search for. This value can be null, numeric, a string, or a date/time. The list of relational operators is pretty much what you would expect: Is Equal To, Is Not Equal To, Is Greater Than, Is Less Than, and so on. However, the kinds of operators that are available depend on whether the attribute is null, numeric, string, or date/time. Table 3 outlines the subtle differences between these operators.

Table 3. Relational operators
Data TypeRelational Operators
NullIs Null, Is Not Null
NumericIs Equal To, Is Not Equal To, Is Greater Than, Is Less Than, Is Greater Than Or Equal To, Is Less Than Or Equal To
StringIs Equal To, Is Not Equal To, Is Like, Is Not Like, Is Greater Than, Is Less Than, Is Greater Than Or Equal To, Is Less Than Or Equal To
Date/TimeUnit Is Equal To, Unit Is Not Equal To, Unit Is Greater Than, Unit Is Less Than, Unit Is Greater Than Or Equal To, Unit Is Less Than Or Equal To, Unit Is
Date/TimeUnit Is Not, Unit Is After, Unit Is Before, Unit Is On Or After, Unit Is On Or Before

(Unit is a date or time unit—millisecond, second, minute, hour, day, week, month, or year.)

When string values are used in a query, the exact string must be provided, without quotation marks, unless the quotation marks are part of the string. If you use either the Is Like or Is Not Like relational operator, you can use wildcard characters as part of the string. Acceptable wildcard characters include those shown in Table 4.

Table 4. Wildcard characters
SymbolMeaning
% (percent)Any string of characters
_ (underscore)Any single character
[ ] (brackets)Any character within a specified range of characters
^ (caret)Any character not within the specified range of characters

For example, if we wanted to query the database for all SMS clients that contained the string FIN in the client name, we might use the value %FIN%. String operators are not case-sensitive unless the SQL code page you’re using uses case-sensitive comparisons.

In real life, your queries will probably be more complex and will consist of several query statements. These statements are connected using logical operators and are grouped for evaluation using parentheses. The three primary logical operators used with SMS queries are AND, OR, and NOT.

An AND operation finds all data that matches two query statements connected by the AND operator. AND operations generally result in a more restricted search since every expression must be satisfied to generate a result.

An OR operation finds all the data that matches any portion of the two statements connected by the OR. As you might expect, OR operations generally result in a broader search since any expression may be satisfied to generate a result.

A NOT operation finds all the data that doesn’t satisfy the statement preceded by the NOT. For instance, in our sample query we might have wanted to exclude all the computers running a version of Windows earlier than Windows 2000 for upgrade purposes.

Other -----------------
- Microsoft Systems Management Server 2003 : Custom SMS Administrator Consoles
- System Center Configuration Manager 2007 : Operating System Install Packages and Image Packages (part 2) - Manual Image Creation, Image Deployment
- System Center Configuration Manager 2007 : Operating System Install Packages and Image Packages (part 1) - Automated Image Creation and Capture
- System Center Configuration Manager 2007 : Operating System Deployment - Computer Associations
- Microsoft Exchange Server 2007 : Load Balancing in Exchange Server 2007
- Microsoft Exchange Server 2007 : Managing a Windows Server 2003 Cluster
- BizTalk Server 2009 : Editing and Resubmitting Suspended Messages (part 2) - Pseudo-Walkthrough to Perform Edits and Resubmits
- BizTalk Server 2009 : Editing and Resubmitting Suspended Messages (part 1) - Sample Flows for Edit and Resubmit
- BizTalk Server 2009 : Building a Resequencing Aggregator
- Windows Server 2003 on HP ProLiant Servers : Security Planning and Design (part 3) - Microsoft Software Update Service and Windows Update Service
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
 
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro