Attaching the Adventure Works 2008 databases.

The other day I needed to attach the Adventure 2008 sample databases to my test server. So I downloaded the self extractor from codeplex and hit run… and got this error:


So, of course I hit Google and got several suggestions along the lines of:

  1. Ensure the database version matches the SQL Server version.
  2. Have only one SQL Instance running.
  3. Put the installer in the correct path.
  4. There is an issue with filestream – download the without filestream option.

All good suggestions but I am working on a test box, I have about half a dozen SQL instances (usually all stopped) with different versions and configurations. I want to be able to install Adventure Works 2008 (because that’s what’s used in a book I’m working through) on to my2008R2 instance (because I want to okay). And finally I want fairly granular control over where I put stuff.

Here’s what I did:

1. Rename the extractor file – change .exe to .zip.

2. Extract the file (double click should do it).

3. In the extracted folder there are sub-folders for the various Adventure Works databases:


4. Each of these subfolders contains a script file (instawdb.sql) and a bunch of csv files.              Load the install script for the database you want into SSMS.

5. The script must be run in SQLCMD mode.  (Query > SQLCMD Mode)

6. Near the top of this script file are two lines:

--:setvar SqlSamplesDatabasePath "C:\Program Files\Microsoft SQL                                     Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\"

--:setvar SqlSamplesSourceDataPath "C:\Program Files\Microsoft SQL                                 Server\100\Tools\Samples\"

7. Uncomment these. The first line should point to where the database files will be created.     Mdf and ldf files will both be created in this directory Sad smile but this can be altered later Smile

8. The second line should point to the location of the subfolder containing the csv files.

9. Run the script – this will create and populate the database of your choice.

10. Rinse and repeat.

This entry was posted in SQL Server. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s