Roll Your Own UDM Schema Generator

Documenting the UDM schema is a common requirement but to the best of my knowledge neither Microsoft nor third-party vendors provide schema generators. While you are waiting for a commercial tool to fill in the gap, you can roll out your own schema generators. Thanks to the Analysis Management Objects (AMO) library, this task is remarkably simple to implement. For example, here is a .NET code snippet that builds upon the DisplayObjectNames sample (included in the SSAS samples). The code loops through all SSAS databases on the server, traverses the dimension attribute hierarchies and measures and displays their names and source columns.

foreach (Database db in server.Databases) {


Console.WriteLine(“{0}”, db.Name);


// Display Dimensions


Console.WriteLine(“\tDimensions:”);


foreach (Dimension dimension in db.Dimensions)

{


Console.WriteLine(“\t\t{0}”, dimension.Name);


// Display attributes


Console.WriteLine(“\t\t\tAttributes:”);


foreach (DimensionAttribute a in dimension.Attributes)


Console.WriteLine(“\t\t\t\t Name: {0}Source: {1}”, a.Name.PadRight(50), GetKeyCollection(a.KeyColumns));

}


// Display Cubes


Console.WriteLine(“\tCubes:”);


foreach (Cube cube in db.Cubes) {


Console.WriteLine(“\t\t{0}”, cube.Name);


// Display Measure Groups


Console.WriteLine(“\tMeasure groups:”);


foreach (MeasureGroup mg in cube.MeasureGroups)

{


Console.WriteLine(“\t\t{0}”, mg.Name);


// Display attributes


Console.WriteLine(“\t\t\tMeasures:”);


foreach (Measure m in mg.Measures)


Console.WriteLine(“\t\t\t\t Name: {0}Source: {1}”, m.Name.PadRight(50), m.Source.ToString());

}

}

}