2011年3月26日 星期六

AMO學習-查詢Partition的相關資訊

SSAS最常用到的就是管理PARTITION,所以我寫了一個簡單的小小程式來檢視PARTITION的相關資訊。
            Server server = new Server();
            server.Connect(@"data source=localhost");
            Database db = server.Databases["RYO"];

            foreach (Cube cb in db.Cubes)
            {
                if (cb.Name == "CubeRYO")
                {
                    foreach (MeasureGroup mg in cb.MeasureGroups)
                    {
                        foreach (Partition pt in mg.Partitions)
                        {
                         //列出所有Partition的名稱和Slice
                         ListBox4.Items.Add(pt.Name + "   " + pt.Slice);
                         QueryBinding qb = new QueryBinding();
                         qb = (QueryBinding)pt.Source;
                          //列出所有Partition的資料來源定義
                         ListBox5.Items.Add(pt.Slice+"     "+qb.QueryDefinition.ToString());

                        }
                    }
                }
            }


呼~想不到AMO還真是好用呢!

沒有留言:

張貼留言