1

I am attempting to catalogue a set of olap-cubes from a SQL Server DB. In the analysis services (SSMS), I can right click a measure_group/table, click partitions, properties, and then use "Script Action to New Query Window". This yields me a script with the various sources used to populate this measure_group.

In the interest of automation, I was wondering if one could retrieve this script through a query. The closest I've gotten is this:

<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
    <RequestType>DISCOVER_PARTITION_STAT</RequestType>
    <Restrictions>
        <RestrictionList>
            <DATABASE_NAME>database_name</DATABASE_NAME>
            <CUBE_NAME>cube_name</CUBE_NAME>
            <MEASURE_GROUP_NAME>measure_group_name</MEASURE_GROUP_NAME>
            <PARTITION_NAME>partition_name</PARTITION_NAME>
        </RestrictionList>
    </Restrictions>
    <Properties>
        <PropertyList>
            <Catalog>database_name</Catalog>
            <Format>Tabular</Format>
        </PropertyList>
    </Properties>
</Discover>


However, the requirement to provide the Partition_Name as a restriction is problematic, because it differs from measure to measure, and would thus require manual entries, defeating the purpose of the script.

Is there a simple query that can be used to get the whole script, without needing to specify more than the database_name and measure_group?

1 Answer 1

0
SELECT 
    MGP.TMEASUREGROUP_NAME AS MeasureGroupName,
    MGP.TMEASUREGROUP_SOURCE AS MeasureGroupSource
FROM 
    $SYSTEM.MDSCHEMA_MEASUREGROUPS AS MGP
WHERE 
    MGP.CUBE_NAME = 'your cube'
    AND MGP.DATABASE_NAME = 'your db'
    AND MGP.TMEASUREGROUP_NAME = 'your measure group'

The $SYSTEM.MDSCHEMA_MEASUREGROUPS schema rowset provides metadata information about measure groups in SSAS. The TMEASUREGROUP_SOURCE column contains the script used to populate the measure group.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, unfortunately that did not work for me. I used this in the end: SELECT * FROM $system.TMSCHEMA_PARTITIONS; And one of the fields had all of the queries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.