Learn more about SQL Server tools

 

Tutorials          DBA          Dev          BI          Career          Categories          Events          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Events

DBA    Dev    BI    Categories

 

Problem Attaching the MDXStepByStep database in SQL Server


By:   |   Read Comments (1)   |   Related Tips: > Analysis Services Development

Problem

I want to attach the MDXStepByStep sample database to learn the MDX language using the Microsoft SQL Server 2008 MDX Step By Step book, but I am unable to attach the MDXStepByStep sample database using the given T-SQL attach database script. How can I attach the MDXStepByStep sample database without the T-SQL Script?

Solution

The Microsoft SQL Server 2008 MDX Step By Step book uses the MDXStepByStep sample database to build the Step-by-Step and Chapter 3 cubes. These two cubes are used to demonstrate MDX language examples. In this tip I will demonstrate how we can attach the MDXStepByStep database without using the T-SQL script provided with the book.

The MDXStepByStep database, Analysis Services Solution and MDX scripts can be extracted from the 9780735626188_OCC.exe file which can be downloaded from here. When we execute the 9780735626188_OCC.exe file, it extracts all the files under the Microsoft Press folder onto your C: drive, you can refer to the below image as a point of reference.

Microsoft_Press_Folder

Let's see what error we get when we try to attach the MDXStepByStep database using the attach_db.sql script. We get the below error message after executing the attach_db.sql script.

Attach_MDXStepByStep_Script_Error

Please follow the below steps to attach the MDXStepByStep database without using the attach_db.sql script.

Step 1 - Copy MDF File

Copy the MDXStepByStep.mdf file from “C:\Microsoft Press\MDX SBS\Setup\SQL Server” to the SQL Server data path which is “C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA” for my installation. As you can see from the below image the MDXStepByStep.mdf file has been copied to the Data folder. Please note your Data folder path may be different based on your MSSQLSERVER installation.

Copy_MDF_To_Data_Folder

Step 2 - Login to SQL Server

Login to your SQL Server with your appropriate credentials, make sure your login has permission to create a database.

SQL_SERVER_LOGIN

Step 3 - Attach Database in SQL Server Management Studio

After successfully logging  into SQL Server, please explore the Databases list, as you can see from the below image the MDXStepByStep database does not exist in the databases list.

Database_List

To attach the database right click on the Databases and click on the Attach option, as shown below.

Attach_Database

Step 4 - Select Database File to Attach in SSMS

Once you click on the attach button, a new attach databases window will open. You can refer to the below image. Click on the add button to add the MDXStepByStep.mdf file.

Attach_Database_Window

Step 5 - Browse for MDF File

Once you clicked on Add button, a new window will open which will display all available mdf files. Please select the MDXStepByStep.mdf file and click on the OK button, you can refer to the below image

Select_MDXStepByStep_MDF_File

Step 6 - Remove LDF File in SSMS

We have added the MDXStepByStep.mdf file, but the MDXStepByStep.ldf file is missing for this database because we didn’t copy a MDXStepByStep.ldf file to “C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA” so we need to remove the missing log file entry. Select MDXStepByStep_log.ldf file entry as shown in below image and click on the Remove button and then click on the OK button.

Remove_MDXStepByStep_Log_File

Step 7 - Verify Attached Database

Congratulations you have successfully attached the MDXStepByStep database. You can verify this by exploring the Databases list in SQL Server Management Studio as shown below.

Attached_MDXStepByStep_Database
Next Steps


Last Update:






About the author
MSSQLTips author Ghanesh Prasad Ghanesh Prasad leads a team in Microsoft Business Intelligence and has over 5 years of experience working with SQL Server.

View all my tips


 









Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Notify for updates 


Get free SQL tips:

*Enter Code refresh code     



Monday, January 25, 2016 - 12:52:13 PM - Kenny Wymore Back To Top

 Thanks for posting this! I was thinking of looking into this book for a while now.

 


Learn more about SQL Server tools