Thursday, July 12, 2012

Process Cube objects using AMO

Today I am going to share code for Processing Cube objects using AMO (Analysis Management Objects) For using AMO, you need to reference the Microsoft.AnalysisServices.dll. Following is the code which you can use for processing. In following sample code, I am processing dimensions first (i.e. ProcessUpdate on dimensions) and then I am processing whole cube. Following is just a sample code, you can modify it as per your requirements


        Dim objServer As Server
        Dim objDatabase As Database

        objServer = New Server
        objServer.Connect("localhost")
        objServer.CaptureXml = True

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

        For Each objDimension As Dimension In objDatabase.Dimensions
            objDimension.Process(ProcessType.ProcessUpdate)
        Next

        For Each objCube As Cube In objDatabase.Cubes
            objCube.Process(ProcessType.ProcessData)
            objCube.Process(ProcessType.ProcessIndexes)
        Next

        objServer.ExecuteCaptureLog(True, True)


Analysis services start processing the cube objects when you run "ExecuteCaptureLog" function.
"ExecuteCaptureLog" function accepts three overloads, first indicates whether the capture log entries will be executed in a transaction, second indicates whether the capture log entries will be executed in a parallel, third one indicates whether the affected objects will be processed.

If you just want to retrieve the generated XMLA then instead of "ExecuteCaptureLog" function, you can use the function named "ConcatenateCaptureLog" which returns XMLA string.

1 comment:

  1. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating MicroStrategy Online Training Hyderabad

    ReplyDelete