Question

I'd like to install AdventureWorks2008 (I just install SQL Server 2008 R2 Express).

Each time I download the recommended version from CodePlex, all I get is a AdventureWorks2008.mdf file. Not only I cannot attach the file from SQL Server Management Studio, but I cannot copy/paste the file directly into the the database.

I've read in several places that I need to use AdventureWorks2008.msi, but I cannot find where to download it.

I just cannot figure out how to install AdventureWorks2008

Thanks for helping

Was it helpful?

Solution

There isn't an .msi file for adventureworks, even though you'll find it mentioned in outdated documentation and books. You aren't alone in finding this confusing -- it seems the web site, files and steps Microsoft provides for installing these databases changes every time I need to install them.

You need to create the database and attach the .mdf file, which is the "data file" referred to in the instructions. (.mdf = primary data file, .ldf = log file, .ndf = secondary data file)

In order to attach the file, you need to make sure you carefully follow the steps here: http://social.technet.microsoft.com/wiki/contents/articles/3735.sql-server-samples-readme-en-us.aspx#Readme_for_Adventure_Works_Sample_Databases

Instructions for 2008R2:

To install AdventureWorks2008R2 OLTP database

  1. Download the AdventureWorks2008R2 Data File.

  2. From File Download, click Save and browse to a location on your local server.

  3. From SQL Server Management Studio, execute the following code:

Case-insensitive Database

CREATE DATABASE AdventureWorks2008R2 
ON (FILENAME = '{drive}:\{file path}\AdventureWorks2008R2_Data.mdf') 
FOR ATTACH_REBUILD_LOG;

As an alternative to step 3, you can attach the database using the SQL Server Management Studio user interface. For more detailed information, see Attach a Database (SQL Server Management Studio).

Note: You must remove the log file from the list of files to attach. This will cause the operation to rebuild the log.

Headache saving tip from Aaron Bertrand:

You should place the mdf file in your normal data folder - SQL Server will already have the proper permissions. You can get this path using

SELECT TOP (1) physical_name FROM master.sys.database_files;

OTHER TIPS

You can directly paste that file into your database directory. For more information you can refer http://tryingmicrosoft.com/error-while-attaching-a-database-to-sql-server-2008-r2/.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top