SSAS AMO Object : Script to find a particular partition in a Measure group

In AMO scripting to find a particular Partition in a Measure group  then see the below script


//Declare AMO server object and get the server detail from connection manager

         amoServer = new AMO.Server();
                amoServer.Connect(myConnectionManager.ConnectionString);
 
// Then get Measure group name using FindByName function
                amoMeasureGroup = amoServer.Databases.FindByName(amoServer.ConnectionInfo.Catalog.ToString()).Cubes.FindByName(myCubeName).MeasureGroups.FindByName(myMeasureGroupName);
                amoServer.CaptureXml = true;
 
// Prepare partition name  which you are going to search
                String myNextPartitionName = myPartitionNamePrefix + myLastPeriodName_source.Replace(":", "_").Replace("-", "_");

                //check wether next partition already exists
                if (!amoMeasureGroup.Partitions.Contains(myNextPartitionName))

Comments

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces