Return to site

Adventureworks 2012 Cube

broken image


C: Program Files Microsoft SQL Server 100 Tools Samples AdventureWorks 2008R2 Analysis Services Project enterprise Adventure Works.sln will contain the solution for SQL Server Enterprise and SQL Server Developer. Solution Explorer looks like the following. In the solution explorer, go to Data Sources and double click on 'Adventure Works.ds'. The cube database that you will create in this tutorial is a simplified version of the Analysis Services multidimensional model project that is part of the Adventure Works sample databases available for download on GitHub. Anime magic knight rayearth sub indo. Adventureworks 2012 Cube Download These downloads are scripts and full database backups (.bak) files that you can use to install the AdventureWorks (OLTP) and AdventureWorksDW (data warehouse) sample databases to your SQL Server instance. Install SSAS AdventureWorks 2012 Multi-Dimensional cube database (on Enterprise Edition) If you want to install SSAS AdventureWorks 2012 Multi-Dimensional database and don't have enough information on how to proceed for the same then this post is designed for you.

  1. Adventureworks Database Download
  2. Adventureworks 2012 Query Samples
Adventureworks 2012 Cube
By: Scott Murray | Updated: 2013-06-26 | Comments (5) | Related: >Analysis Services Administration
Problem

Cube developer often flippantly use the term XMLA in there discussion of maintaining, scripting, backing up, and restoring cubes and other SSAS objects; what exactly is XMLA and how can it be used? Check out this tip to learn more.

Solution

XMLA is an XML based, exclusive protocol used to handle communication between clients and a SSAS database. It is SOAP based and is designed to be a standard access point for any multidimensional source. XMLA is the driving scripting language behind many of the tasks within SSAS. Some of the scripting tasks that can accomplished by XMLA include:

  • Creating and changing objects
  • Processing objects
  • Handling connections
  • Backup and restores
  • Designing aggregations
  • Merging partitions

XMLA contains 2 basic methods, Discover and Execute. The Discover method retrieves lists of information in XML format while the Execute method sends commands to the SSAS instances for execution by the instance. We will discuss several of the execute tasksand methods in the next several sections of this tip.

Creating and Altering Objects with SSAS XMLA

Adventureworks Database Download

Using the Create or Alter XMLA commands, new SSAS objects can be created or existing objects changed based on the issued command. Included in the list of potential objects that can be changed by Create or Alter are:

  • Databases
  • Dimensions
  • Cubes
  • Roles
  • Datasources
  • Partitions
  • Measure groups

One question that often surfaces in initial discussions on XMLA is where do we execute these scripts. Simply openSQL Server Management Studio (SSMS) and connect to yourAnalysis Services database. Apple magic keyboard model number. Generally, your default query type will be MDX, so to execute an XMLA script, select File from the Ribbon Menu, then New, then Analysis Services XMLA Query.


At this point we are ready to create and run some XMLA scripts. All the examples for this tip will come from the AdventureWorks 2012 DW SSAS database, which is freely available on CodePlex. Of course, the difficult part is know what fields are needed in your script. A good way to see what is needed in a particular script is to allow Management Studio to generate the scripts for you. Following the below example to create a new cube based on an existing cube, first right click on the selected cube. Then, click Script Cube as; next click Create To, and then last select New Query Editor Window.


SSMS produces the create cube XMLA script which will generate an exact replica of the selected cube, Adventure Works in our example. As the script is many lines long only a small portion of the script is included below; however I highly recommend you try this process on your internal test system and review the entire script. Furthermore, if you attempt to execute this exact script on the same SSAS database, an error would result, because a cube by the same name already exists.

Most objects can be scripted in a similar way; however much care should be taken when executing the scripts. Any changes made to the individual values are applied and overwritten to the object when the script is executed, and if a particular property is omitted, then the property value is not set at all!

The create element, which is part of the execute method, allows the designer to code the entire creation of new SSAS objects. The create element requires 1) a ParentOject element which defines the object's parents elements based where the object resides in the hierarchy of objects (i.e. Database > Cube > Measure Group > Partition), and 2) certain ObjectDefinitions which are synonymous with the object's properties. The ObjectDefinitions needed depend on the object being created. Although Books Online (BOL) is somewhat sparse on what items are required, a good site to review is the Analysis Services Scripting Language (ASSL) XML Reference. Using the script below which creates a new partition called Finance_2 as an example, the ParentObjects of that partition includes:

  1. Database - AdventureWorksDW2012Multidimensional-EE
  2. Cube - Adventure Works
  3. Measure Group - Fact Finance

Again, the difficult part is knowing what fields are needed in the ObjectDefinitions section. For the Partition element used in the below example, the ObjectDefinitions for the partition element can be found at: http://msdn.microsoft.com/en-us/library/ms126977.aspx.

Photo editor 2019 download. Looking at the above scripts, you will notice each of the distinct parts of the XMLA:

  • First, the Create Element is used
  • Next, the Parent Object which defines the objects owner is included
  • Last, the object's definition elements are defined and include the type of object to be created, the object's name and id, and several additional properties pertaining to this new partition.

Running this script produces the results shown in the below screen print; these results are certainly not descriptive of a successful execution. However, we can see in our partition list, after a refresh, that we now have a second partition called Finance_2.

If we run the XMLA script again though, we immediately see an error message that states that the partition already exists!


The basic structure of the alter element, displayed below, is similar to the Create script except the header row is now Alter. Additionally, no ParentObject is used, and note that all the ObjectDefinitions (aka properties) for the object are specified, so care must be taken when changing and running the script to be sure all required elements are included as the entire object is overwritten when the script is executed!

Of course, in addition to creating and altering objects, the delete element command is also available; please be careful to not confuse the Delete element with the Drop element which removes attributes from a dimensions. An example of the delete command is listed below; the entire hierarchy path must be specified; this syntax is similar to the how the ParentObject was expressed in the create command.

Backup and Restore with SSAS XMLA

Probably the most widely expressed reason for using a XMLA script is to backup and restore a SSAS database. As displayed below, this script is potentially one of the simpler in scope. First the backup method is expressed. Next the database ID is specified, and then last the backup options are written. In the below script, the file name, the allow overwrite, and the apply compression options are included. One other common option is adding a password to the backup.

This entire process could be automated using a SQL Agent job or even via PowerShell as described by Daniel Calbimonte in Automate SQL Server Analysis Services Tasks with PowerShell - Part 2. Of course, the restore command is similar to the backup command, so we will not display it here. However, a great MSSQLTip by Ashish Kumar Mehta describes the restore process in detail. A complete list of XMLA command elements can be found at: http://msdn.microsoft.com/en-us/library/ms187159.aspx, and be sure to review the Next Steps section for other handy MSSQLTips using XMLA. Microsoft office 2016 pro mac. Finally, SSAS also offers many DMV's which address several of the query needs that could be achieved using the Discover element; I am hoping to do atip on these DMV's very soon.

Conclusion

XMLA is the XML based protocol used to communicate with an Analysis Server. It can be used to script discover and execute methods including Create and Alter, Backup and Restore, and Processing cube objects. These scripts are run in Management Studio and can be automated via PowerShell or the SQL Agent.

Next Steps
  • Check out these additional resources

Last Updated: 2013-06-26

Adventureworks 2012 Query Samples





About the author
Scott Murray has a passion for crafting BI Solutions with SharePoint, SSAS, OLAP and SSRS.
View all my tips
Related Resources






broken image