How can you copy dimensions from one SQL Server Analysis Services (SSAS) Project to another? Are there any options to do so? This tip is for SQL Server BI Professionals who need to copy dimensions from one SSAS project to another. I will outline three approaches to address this need in this tip.
There are three solutions to copy dimensions from one SQL Server Analysis Services (SSAS) Project to another SSAS Project. Those options are:
XMLA (trust me, is not that hard and I promise to explain this for beginners)
Copy the dimensions file and add the item in the destination project
In this tip, I am going to use SQL Server 2012, but the solutions are applicable to SQL Server 2008 or 2005. As a point of reference, here are the required items:
In this example I am going to copy the dimension date from a project named AdventureWorks (i.e. Project A) to a solution named Multidimensional6 (i.e. Project B) as shown below:
Sometimes we have nice dimensions with structures, attributes already tested in other projects and we want to use them again as shown below.
Option 1 - SQL Server Analysis Services Linked Dimensions
The first method to use existing dimensions is to use the linked dimensions functionality. In order to add the dimension in Project B from Project A, go to Project B and in the dimension folder right click and select "New Linked Dimension" as shown below.
You will have a Wizard to connect to the other project. If you do not have a connection, press the "New" button as shown below.
Now select the dimensions that you want to add as shown below.
Finish the wizard.
The new dimension will now be available, but you will not be able to change the structure, since it is a linked dimension. The new dimension was not physically added.
You can however see the translation section as shown below.
If you have the default configuration, you will see the following error message in the browser tab of the linked dimension:
Here is the error message "Errors in the OLE DB provider. The server returned the following error: (Errors related to feature availability and configuration: The 'Linking to other instance.' feature is disabled by the 'ConfiguationSettings\feature\LinkformOtherInstanceEnabled' property.)."
OK, it seems that we have to enable a property. The question is where do I do that?
The answer is in the SQL Server Management Studio. Log on to Microsoft Analysis Server, right click on the server name, and select "Properties".
Check the box for "Show Advanced (All) Properties" as shown below..
Set the LinkFromOtherInstances property to "true" as shown below.
Alternatively, we can configure the property in the msmdsrv file. This file contains the SSAS properties. This file is in the Microsoft SQL Server\MSAS\OLAP\Config folder as shown below.
In the msdmsrv file to enable the property, by setting it to 1 as shown below.
Once you have configured the property, restart the SSAS Service as shown below.
Once enabled, go to SSDT or BIDS and process the dimension as shown below. Now you will be able to browse the dimension.
You may wonder why is the LinkedFromOtherInstances is disabled by default? There are some disadvantages of using linked dimensions. The first problem is the dependency on the other project. If someone changes the other dimension, it may affect all of the projects using it. There is a pretty nice A href="/sqlservertip/2351/controlling-the-use-of-linked-objects-in-sql-server-analysis-services/">article about this written by Siddharth Mehta if you want to read more about it.
Now, what is the next solution? Let's see how we can do this with XMLA.
Copy SQL Server Analysis Services Dimensions with XMLA
What we are going to do in this solution is:
Generate a XMLA script from the dimension in Project A.
Modify it the XMLA script and run it in Project B.
Here are the detailed steps:
IIn Project A (the Adventureworks solution) go to SQL Server Management Studio (SSMS) and connect to Analysis Services. Go to the dimensions and select the "Date" dimension. In the date dimension, select "Script Dimension as" > "Create To" > "New Query Editor Window". These actions generate the script to create the dimension.
The XMLA script is from the AdventureWorksDW2012Multidimensional-EE database. We need to change the XMLA code to create the dimension in the other project, so me will change the DatabaseID.
Our Project B is named "MultidimensionalProject6", but sometimes the name and ID are not the same. For example, if your database was originally named "DatabaseA" and then you change the name to "DatabaseB". Although, the name is changed, the ID remains the same. In order to verify the ID, in the SSMS go to the MultidimensionalProject6, right click and select the "Properties" option.
Verify the ID value. In this example the "Name" and "ID" are the same.
Now, change the DatabaseID from "AdventureWorksDW2012Multidimensional-EE" to "MultidimensionalProject6". Since I added a linked dimension, I am also changing the "Dimension Name" and "ID", but if you did not try the linked dimension option, then this step is not necessary. Press F5 to create the dimension by executing the code.
You may have the following error after pressing F5 to execute the code.
The problem occurs when the Data Source View ID from Project A and Project B are different. In order to see the Data Source View ID, right click in the Data Source View folder and select "Properties" as shown below.
Verify the ID.
Now in the XMLA script, change the DatasourceViewID from "AdventureWorks" to the name of the "Project B" and press F5 again to execute the code.
If you press F5, the new dimension will be displayed successfully.
Add an existing item to a SQL Server Analysis Server Solution
The last solution is to go to the Solution in SSDT or BIDS and add an existing item and select the dimension. I am not going to explain in detail this last solution because it is a well- known solution and it was already explained by other people here.
In this tip we outlined three different methods to add an existing dimension in another SSAS solution. Work through the examples in your environment and see which one makes most sense in your environment.
I did same steps as guided, i have changed "LinkFromOtherInstances property to "true"" as well by doing this i am able to process the Date dimension but getting below error while processing the cube.
Processing Dimension 'Date' completed. Start time: 12/18/2012 12:36:55 PM; End time: 12/18/2012 12:36:55 PM; Duration: 0:00:00 Processing Dimension Attribute '(All)' completed. Start time: 12/18/2012 12:36:55 PM; End time: 12/18/2012 12:36:55 PM; Duration: 0:00:00 Processing Dimension Attribute 'Calendar Due Date Calculations' completed. Start time: 12/18/2012 12:36:55 PM; End time: 12/18/2012 12:36:55 PM; Duration: 0:00:00 Processing Dimension Attribute 'Calendar Year' completed. 6 rows have been read. Start time: 12/18/2012 12:36:55 PM; End time: 12/18/2012 12:36:55 PM; Duration: 0:00:00 SQL queries 1 SELECT DISTINCT [dbo_DimDate].[CalendarYear] AS [dbo_DimDateCalendarYear0_0] FROM [dbo].[DimDate] AS [dbo_DimDate] Processing Dimension Attribute 'Fiscal Year' completed. 6 rows have been read. Start time: 12/18/2012 12:36:55 PM; End time: 12/18/2012 12:36:55 PM; Duration: 0:00:00 SQL queries 1 SELECT DISTINCT [dbo_DimDate].[FiscalYear] AS [dbo_DimDateFiscalYear0_0] FROM [dbo].[DimDate] AS [dbo_DimDate] Errors and Warnings from Response Errors in the high-level relational engine. The data source view does not contain a definition for the 'Calendar_x0020_Due_x0020_Date_x0020_Calculations' column in the 'dbo_DimDate' table or view. Errors in the OLAP storage engine: An error occurred while the dimension, with the ID of 'Date', Name of 'Date' was being processed. Errors in the OLAP storage engine: An error occurred while the 'Calendar Due Date Calculations' attribute of the 'Date' dimension from the 'SSASTESTCUBE' database was being processed. Internal error: The operation terminated unsuccessfully. Server: The operation has been cancelled.
Error 4 Errors related to feature availability and configuration: The 'Linking inside same server instance.' feature is not included in the 'Standard Edition' SKU. 0 0
Thanks in Advance,
Monday, December 17, 2012 - 8:49:57 PM - Daniel Calbimonte