简体   繁体   中英

Extract data from MDX query string

I have hundreds of MDX queries captured from SQL Analysis Services (Extended Events).

They look like this :

SELECT {[Measures].[ Count - Sales],[Measures].[ Count - Customers],[Measures].[Revenue]} DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(DrilldownMember({{DrilldownMember({{DrilldownLevel({[DimDate].[Calendar Date].[All]},,,INCLUDE_CALC_MEMBERS)}}, {[DimDate].[Calendar Date].[Calendar Year].&[2014],[DimDate].[Calendar Date].[Calendar Year].&[2015],[DimDate].[Calendar Date].[Calendar Year].&[2016],[DimDate].[Calendar Date].[Calendar Year].&[2017],[DimDate].[Calendar Date].[Calendar Year].&[2018],[DimDate].[Calendar Date].[Calendar Year].&[2013]},,,INCLUDE_CALC_MEMBERS)}},

I need to write a bit of c# to extract data as :

[Measures].[ Count - Sales]
[Measures].[ Count - Customers]
[Measures].[Revenue]
[DimDate].[Calendar Date].[All]
[DimDate].[Calendar Date].[Calendar Year]

etc..

I don't mind if I get repeating members.

I can rely ranges being : [Measures] to second ] [Dim to second or third ]

I'm leaning towards using Regex to extract data :

Any ideas on the regex to capture above elements?

This should work:

\[[^\]]+\]\.\[[^\]]+\](\.\[[^\]]+\])?

Explanation:

\\[[^\\]]+\\] - open bracket, anything until close bracket, close bracket (let's call it BRACKETED).

It's followed by dot, and another BRACKETED. Last section of dot and BRACKETED is optional.

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