08 January 2008

How do I install the AdventureWorks sample database with SQL Server 2005 Express?

File Download:

  1. Navigate to: http://www.codeplex.com/MSFTDBProdSamples.
  2. From the: Releases tab, click: SQL Server 2005 (hyperlink).
  3. Scroll down and click: AdventureWorksLT.msi.
  4. Save the file to your desktop or other known location.
  5. Once the download is complete, click: Run (or navigate to the location where you saved the file and double-click: AdventureWorksLT.msi) to start the install.
  6. Follow the prompts (using the default selections) to complete the install.

DB Permissions Configuration:

  1. From the keyboard, press: Windows Key + E to launch Windows Explorer.
  2. In Windows Explorer, navigate to: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data.
  3. Right-click: AdventureWorksLT_Data.mdf then select: Properties.
  4. Click: Security > Edit > Add.
  5. Type your login name into the: Enter the object names... textbox then click: Check Names. Your entry will automatically resolve to: MACHINENAME\Login.
  6. Click: OK.
  7. Select your login name from the: Groups or usernames list.
  8. In the: Permissions for LoginName box, click: Full control then click: OK > OK. You should now be back at the Windows Explorer window.
  9. Right-click: AdventureWorksLT_Log.ldf then repeat this process to change the user permissions for that file as well.

SQL Server Management Studio Configuration:

  1. Launch Microsoft SQL Server Management Studio Express and connect to your local server. Ensure that the default connection settings are used.
  2. From Object Explorer, right-click: Databases then click: Attach. The: Attach Databases dialog will appear.
  3. Click: Add.
  4. Click: AdventureWorksLT_Data.mdf then click: OK.
  5. Click: OK. You should now be at the main window for: Microsoft SQL Server Management Studio Express.
  6. In Object Explorer, expand: Databases > AdventureWorksLT > Tables.
  7. Right-click: dbo.BuildVersion then select: Script Table as > SELECT to > New Query Editor Window.
  8. Press: F5. The query will return the build version, confirming a successful installation.

Possible Problems:

Error: The database 'AdventureWorks' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported. Could not open new database...

Error: Error 27506. Error executing SQL script sqlscript.sql. Line 17. The database 'AdventureWorksLT' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported (948)...

These errors are generated when you attempt to install AdventureWorks for SQL Server 2008 on SQL Server 2005. The CodePlex website contains two versions of the database: One for SQL Server 2005 and one for SQL Server 2008. Repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: Error 1722.There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel...

This error is also generated after attempting to install AdventureWorks for SQL Server 2008 on SQL Server 2005, though this error code may be specific to a Windows XP installation. Either way, repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: CREATE File encountered operating system error 5(access denied) while attempting to open/create the file.... MS SQL error 5123...

This error (or similar) is related to file permissions for: AdventureWorksLT_Data.mdf and/or AdventureWorksLT_Log.ldf. In either case, repeat the: DB Permissions Configuration: portion of this tutorial.

3 comments:

Ya'aqov said...

Many thanks - I'm a developer getting started in Database Administration, and this blog entry got me rolling in about 5 minutes. The books I've read on SQL Server seem to assume the reader already knew these steps - keep up the good work!

-James
Charlotte, NC

iBorn2Code said...

That was really very simple and step by step guide which I didn't find in other places, I works like a charm with many thanks. Hope to see more posts on your helpful blog.

Farhad
Osoyoos, BC

Anonymous said...

AB - thank you for this post. I am working through chapter 15 of Jesse Liberty's Programming C# 3.0. Your directions are more detailed to the point that I could adapt them for SQL Server Express 2008 and get up and running to try out his sample code.