Reputation: 165
How to get a cube name
from the given MDX
query.
For example: I have a query like as below,
SELECT [Date].[Calendar Year].MEMBERS on 0 , TOPCOUNT( [Product].[Product].MEMBERS , 10 , [Measures].[Sales Amount] ) ON 1 FROM [Adventure Works]
How can I get the cube name
Adventure Works from the above query?
Upvotes: 4
Views: 520
Reputation: 591
You need to parse the MDX. How sophisticated your parser needs to be depends on the effort you can invest, your tolerance for potential errors, and potentially as well on your experience with building parsers.
Just an outline:
You should search for the keyword FROM
. In MDX grammar, this can only be followed by a cube name or by a subselect. A subselect can be recognized by a a parenthesis followed by the keyword SELECT
.
And keywords can be recognized, as they are not contained in comments, strings, or square brackets.
As subselects should be properly nested, I would think you probably even could just search for the last keyword FROM
. This should always be followed by the cube name, either in square brackets, or as a valid identifier.
Upvotes: 1