none
HOw to read Partition Query Definition using AMO

    Question

  • Hi ,

    I would like to read the Querydefinition of the partition in a cube using AMO .

    how can i do this.

    Regards,

    Santosh

    Friday, December 02, 2011 1:45 PM

Answers

  • Hi Santosh,

    You can use following AMO code;

     

    Dim objServer As Server

            Dim objDatabase As Database

            Dim objCube As Cube

            Dim objMeasureGroup As MeasureGroup

            Dim objPartitionSource As QueryBinding

            Dim strQuery As String

     

            objServer = New Server

            objServer.Connect("localhost")

     

            objDatabase = objServer.Databases.FindByName("Adventure Works DW 2008R2")

            objCube = objDatabase.Cubes.FindByName("Adventure Works")

     

            objMeasureGroup = objCube.MeasureGroups.FindByName("Internet Sales")

            For Each objPartition As Partition In objMeasureGroup.Partitions

                objPartitionSource = objPartition.Source

                strQuery = objPartitionSource.QueryDefinition

            Next

     

            objServer.Disconnect()


    Aniruddha http://aniruddhathengadi.blogspot.com/
    • Proposed as answer by Aftab Ansari Wednesday, December 07, 2011 11:21 AM
    • Marked as answer by santoshdvn Friday, December 09, 2011 5:59 AM
    Wednesday, December 07, 2011 11:11 AM

All replies

  • Hi Santosh,

    I did not see any method / property can be used to extract the partition querydefinition in AMO OLAP class. I think you could try get the cube XMLA and then manage to retrieve the query defintion.

    regards,
    Jerry

    Wednesday, December 07, 2011 9:43 AM
    Moderator
  • Hi Santosh,

    You can use following AMO code;

     

    Dim objServer As Server

            Dim objDatabase As Database

            Dim objCube As Cube

            Dim objMeasureGroup As MeasureGroup

            Dim objPartitionSource As QueryBinding

            Dim strQuery As String

     

            objServer = New Server

            objServer.Connect("localhost")

     

            objDatabase = objServer.Databases.FindByName("Adventure Works DW 2008R2")

            objCube = objDatabase.Cubes.FindByName("Adventure Works")

     

            objMeasureGroup = objCube.MeasureGroups.FindByName("Internet Sales")

            For Each objPartition As Partition In objMeasureGroup.Partitions

                objPartitionSource = objPartition.Source

                strQuery = objPartitionSource.QueryDefinition

            Next

     

            objServer.Disconnect()


    Aniruddha http://aniruddhathengadi.blogspot.com/
    • Proposed as answer by Aftab Ansari Wednesday, December 07, 2011 11:21 AM
    • Marked as answer by santoshdvn Friday, December 09, 2011 5:59 AM
    Wednesday, December 07, 2011 11:11 AM