Data Mining Query Interfaces
Data mining queries are based on the Data Mining Extensions (DMX) language. You use DMX for all prediction and modeling tasks, including classification, risk analysis, generation of recommendations, and linear regression. You can also retrieve the patterns and statistics that were generated when you processed the model.
The syntax for a prediction query using DMX is similar to the syntax for a query in Transact-SQL. Both SQL Server Management Studio and SQL Server Data Tools (SSDT) provide tools that help you build DMX prediction queries.
This topic describes the interfaces that you can use to create and execute data mining queries using DMX.
SQL Server provides the following tools that you can use to build prediction queries, content queries, and data definition queries against data mining objects:
Prediction Query Builder
Integration Services data mining components
Prediction Query Builder is included in the Mining Model Prediction tab of Data Mining Designer, which is available in both SQL Server Management Studioand SQL Server Data Tools (SSDT).
When you use the query builder, you can use graphical tools to select a mining model, add new case data, and add prediction functions. The Prediction Query Builder includes a text editor that you can use to modify the query manually, and a simple Results pane to view the results of the query.
The Query Editor in SQL Server Management Studio provides tools that you can use to build and run DMX queries. You can connect to an instance of SQL Server Analysis Services, and then select a database, mining structure columns, and a mining model. The Metadata Explorer contains a list of prediction functions that you can browse.
SQL Server Management Studio provides interactive DMX query templates that you can use to build DMX queries. If you do not see the list of templates, click View on the toolbar, and select Template Explorer. To see all Analysis Services templates, including templates for DMX, MDX, and XMLA, click the cube icon.
To build a query using a template, you can drag the template into an open query window, or you can double-click the template to open a new connection and a new query pane.
For an example of how to create a prediction query from a template, see Create a Singleton Prediction Query from a Template.
The Data Mining Add-in for Microsoft Office Excel also contains a number of templates, along with an interactive query builder which can help you compose complex DMX statements. To use the templates, click Query, and click Advanced in the Data Mining Client.
You can also include prediction queries as part of a SQL Server Integration Services package. The following tasks and transformations in Integration Services support the creation and execution of DMX prediction queries and DMX statements.
Data Mining Query task
Executes DMX queries and other DMX statements as part of a control flow.
The task editor provides the Prediction Query Builder, and a text box for modifying the DMX query manually. However, the task editor cannot validate the query against objects in an Analysis Services solution. Therefore, it is best to create a query within SQL Server Data Tools or Management Studio and then paste the text of the statement or query into the task editor.
Data Mining Query transformation
Executes a prediction query within a data flow, using data supplied by a data flow source.
The task editor provides the Prediction Query Builder, and a text box for modifying the DMX query manually.
The transformation can only be used for creating queries that use data in the data flow; that is, queries that use the PREDICTION JOIN syntax. This component cannot be used for executing content queries or other kinds of DMX statements.
You can create custom applications that execute queries against data mining models by using a variety of programming languages, in combination with server protocols such as OLE DB or Analysis Services ADOMD client. For more information, see Data Mining Programming.
However, XMLA constitutes the underlying message format for all interactions with an Analysis Service server. Within an XMLA message, queries are represented differently depending on whether you are sending a prediction query based on DMX, a content query, or a query that retrieves model metadata using the data mining schema rowsets.
The text of prediction queries (and all other DMX statements) is sent in XMLA by using the Execute Method (XMLA) method, with the DMX query placed as text within the Statement Element (XMLA) element of the XMLA Command Element (XMLA) element.
To retrieve model content and model metadata, such as the number of clusters, the attributes used in decision trees, the date the model was last processed, and the algorithm parameters used when creating the model, you can use the Discover Method (XMLA) method and specify one of the data mining schema rowsets in the RequestType Element (XMLA) header. To narrow the scope of the query, enter criteria as restrictions within the RestrictionList Element (XMLA) element.