简体   繁体   中英

How to get a cube name from the given MDX query

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?

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 aa 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM