Sending XMLA to Analysis Services the easy way

I love Chris Harrington's Thin Olap site http://www.activeinterface.com/thinolap.html which has a stack of examples on sending XMLA using VBScript.

However I recently came across an easier way to send XMLA to Analysis Services using .Net. There is an assembly called Microsoft.AnalysisServices.XMLA.dll that is distributed with Analysis Services 2005, it is installed in GAC on the server or can be found in “C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies“ by default.

If you add a reference to this assembly you can then run the following C# code to send an XMLA script that was created in SMSS. I used the following code to create an entire copy of the Adventure Works database.

  1 using System; 
  2 using System.Collections.Generic; 
  3 using System.Text; 
  4 using Microsoft.AnalysisServices.Xmla; 
  5 using System.IO; 
  6  
  7 namespace xmlaCmd 
  8 { 
  9     class Program 
 10     { 
 11         static void Main(string[] args) 
 12         { 
 13             XmlaClient clnt = new XmlaClient(); 
 14             clnt.Connect(@"localhost\sql05"); 
 15             string xmla = File.ReadAllText(@"c:\data\AdvWrksDW2.xmla"); 
 16             clnt.Send( xmla, null ); 
 17             clnt.Disconnect(); 
 18         } 
 19     } 
 20 }

If I get time in the future I would like to try and build a more complete xmla client, but this will give you a basic idea of the approach.

Print | posted on Thursday, May 25, 2006 9:03 PM