2.5. Querying Using the MDX Query Editor

Just to recap, MDX is a language that allows you to query multidimensional databases similar to the way SQL is used to query relational databases. MDX is used to extract information from Analysis Services cubes or dimensions. Whereas SQL returns results along two axes — rows and columns — MDX returns data along multiple axes. You learn about MDX in depth in Chapters 3 and 10. For now, let's look at a simple MDX query to learn how to execute it and view its results.

The syntax of a typical MDX query is as follows:

SELECT [<axis_specification>
    [, <axis_specification>...]]
 FROM [<cube_specification>]
[WHERE [<slicer_specification>]]

The MDX SELECT clause is where you specify the data you need to retrieve across each axis. The FROM clause is used to specify the cube from which you retrieve the data. The optional WHERE clause is used to slice a small section of data from which you need results.

In Analysis Services 2000, an MDX Sample application was included that could be used to send queries to cubes and retrieve results. In Analysis Services 2005 and 2008, query editors are integrated right into SSMS for sending queries to SQL Server and Analysis Services instances. These query editors have IntelliSense (dynamic function name completion) capabilities built in. When MDX queries are saved from SSMS they are saved with the extension.mdx. You can open the MDX query editor in SSMS by selecting File New Analysis Services MDX Query as shown in ...

Get Professional Microsoft® SQL Server® Analysis Services 2008 with MDX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.