How to: Create a Data Mining Query by Using XML/A
You can create a variety of queries against data mining objects by using AMO, DMX, or XML/A.
XML is used for communication between the Analysis Services server and all clients. Therefore, although it is generally much easier to create content queries by using DMX, you can write queries by using the DISCOVER and COMMAND statements in XML/A, either by using a client that supports the SOAP protocol, or by creating an XML/A query in SQL Server Management Studio.
This topic explains how to use the XML/A templates that are available in SQL Server Management Studio to create a model content query against a mining model stored on the current server. For general information about working with templates, see How to: Use Templates in SQL Server Management Studio.
Querying Data Mining Schema Rowsets by Using XML/A
To open an XML/A template
In SQL Server Management Studio, on the View menu, click Template Explorer.
Click the cube icon to open the list of Analysis Services templates.
In the list of template categories, expand XMLA, expand Schema Rowsets, and double-click Discover Schema Rowsets to open the template in the appropriate code editor.
In the Connect to Analysis Services dialog box, complete the connection information and then click Connect. A new query editor window opens, populated with the Discover Schema Rowsets template.
To discover column names from the MINING MODEL CONTENT schema rowset
With the Discover Schema Rowsets template open, click Execute.
A list of schema rowsets is returned in the Results pane that contains the rowset names and rowset columns for all rowsets available on the current instance.
In the Query pane, place the cursor after <Restriction List> and press ENTER to add a new line.
Place the cursor on the blank line and type <SchemaName>DMSCHEMA_MINING_MODEL_CONTENT</SchemaName>
The complete section for restrictions should appear as follows:
<Restrictions>
<RestrictionList>
<SchemaName>DMSCHEMA_MINING_MODEL_CONTENT</SchemaName>
</RestrictionList>
</Restrictions>
Click Execute.
The Results pane shows a list of column names for the specified schema rowset.
To create a content query using the MINING MODEL CONTENT schema rowset
In the Discover Schema Rowsets template, change the request type by replacing the text inside the request type tags.
Replace this line:
<RequestType>DISCOVER_SCHEMA_ROWSETS</RequestType>
with the following line:
<RequestType>DMSCHEMA_MINING_MODEL_CONTENT</RequestType>
Change the restriction list to specify a mining model by name, by adding a new condition to the restriction lists.
In the template, place the cursor after <Restriction List> and press ENTER to add a new line.
Place the cursor on the blank line and type <MODEL_NAME>My model name</MODEL_NAME>
The complete section for restrictions should appear as follows:
<Restrictions>
<RestrictionList>
<MODEL_NAME>My model name</MODEL_NAME>
</RestrictionList>
</Restrictions>
Click Execute.
The Results pane displays the schema definition, together with the values for the specified model.
See Also