SELECT FROM <model>.CONTENT (DMX)
Returns the mining model schema rowset for the specified data mining model.
The SELECT FROM <model>.CONTENT statement returns content that is specific to each algorithm. For example, you might want to use the descriptions of all the rules of an association rules model in a custom application. You can use a SELECT FROM <model>.CONTENT statement to return values in the NODE_RULE column of the model.
The following table lists the columns that are included in the mining model content.
Algorithms might interpret the columns differently in order to correctly represent the content. For a description of the mining model content for each algorithm, and tips on how to interpret and query the mining model content for each model type, see Mining Model Content (Analysis Services - Data Mining).
CONTENT rowset column
A catalog name. NULL if the provider does not support catalogs.
An unqualified schema name. NULL if the provider does not support schemas.
A model name. This column cannot contain a NULL.
The name of the attribute that corresponds to the node.
The name of the node.
The unique name of the node within the model.
An integer that represents the type of the node. .
The node GUID. NULL if no GUID.
A label or a caption that is associated with the node. Used primarily for display purposes. If a caption does not exist, NODE_NAME is returned.
The number of children that the node has.
The unique name of the node's parent.
A description of the node.
An XML fragment that represents the rule embedded in the node. The format of the XML string is based on the PMML standard.
An XML fragment that describes the path from the parent to the node.
The probability of the path that ends in the node.
The probability of reaching the node from the parent node.
A table that contains statistics that describe the distribution of values in the node.
The number of cases in support of this node.
The following code returns the ID of the parent node for the decision trees model that was added to the Targeted Mailing mining structure.
SELECT MODEL_NAME, NODE_NAME FROM [TM Decision Tree].CONTENT WHERE NODE_TYPE = 1
The following query uses the IsDescendant function to return the immediate children of the node that was returned in the previous query.
Because the value of the NODE_NAME is a string, you cannot use a sub-select statement to return the NODE_ID as an argument to the IsDescendant function.
SELECT NODE_NAME, NODETYPE, NODE_CAPTION FROM [TM Decision Tree].CONTENT WHERE ISDESCENDANT('0')
Because the model is a decision trees model, the descendants of the model parent node include a single marginal statistics node, a node that represents the predictable attribute, and multiple nodes that contain input attributes and values. For more information, see Mining Model Content for Decision Tree Models (Analysis Services - Data Mining).
The mining model content frequently contains interesting information about the model in nested table columns. The FLATTENED keyword lets you retrieve data from a nested table column without using a provider that supports hierarchical rowsets.
The following query returns a single node, the marginal statistics node (NODE_TYPE = 26) from a Naïve Bayes model. However, this node contains a nested table, in the NODE_DISTRIBUTION column. As a result, the nested table column is flattened and a row is returned for every row in the nested table. The value of the scalar column MODEL_NAME is repeated for each row in the nested table.
Also, notice that if you specify only the name of the nested table column, a new column is returned for each column in the nested table. By default, the name of the nested table is prefixed to the name of each nested table column.
SELECT FLATTENED MODEL_NAME, NODE_DISTRIBUTION FROM [TM_NaiveBayes].CONTENT WHERE NODE_TYPE = 26
The following example demonstrates how to return only some of the columns from the nested table by using a sub-select statement. You can simplify the display by aliasing the table name of the nested table, as shown.
SELECT MODEL_NAME, (SELECT ATTRIBUTE_NAME, ATTRIBUTE_VALUE, [SUPPORT] AS t FROM NODE_DISTRIBUTION) FROM TM_NaiveBayes.CONTENT WHERE NODE_TYPE = 26