Installing the Adventure Works R2 sample Database

Source: Internet
Author: User
Tags mssqlserver management studio sql server management sql server management studio

SQL Server R2 Many related articles are based on the Adventure Works database, but the database is not installed by default during SQL Server R2 installation and needs to be downloaded from the CodePlex Web site and installed manually.

Microsoft provides two ways to install the Adventure Works Database, the first is the data file method, as long as the SQL Server Management Stuido attached to the data file, and the second is the Scripting way, You need to manually execute the script file in sqlcmd to install it.

Open Web site http://msftdbprodsamples.codeplex.com/releases/view/59211, select the appropriate installation method file download.

Installing Adventure Works using the data file method

1. Select download Mode "adventureworks2008r2 Datafile", download adventureworks2008r2_data.mdf Save to directory C: \ AdventureWorks 2008R2.

2. Open SQL Server Management Studioto perform additional database tasks. In the Attach Database dialog box, add the adventureworks2008r2_data.mdf file.

4. Delete the log file in the database details list and click the "OK " button, so the AdventureWorks database is attached successfully.

To install Adventure Works by using a scripted approach

1. Select the download mode "AdventureWorks 2008R2 OLTP Script" to extract the downloaded files to C:\AdventureWorks 2008r2\adventureworks 2008R2 OLTP directory. there should be a lot of CSV files and a file named Instawdb.sql in the extracted directory .

2. Open the instawdb.sql file with Notepad and locate the following:

--:setvar sqlsamplesdatabasepath   "C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\data\"-- : Setvar sqlsamplessourcedatapath "C:\Program Files\Microsoft SQL Server\100\tools\samples\"

Replace with:

: Setvar sqlsamplesdatabasepath   "C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\data\": Setvar sqlsamplessourcedatapath "C:\AdventureWorks 2008r2\adventureworks 2008R2 Data warehouse\"

Here you add two environment variables using setvar : Thesqlsamplesdatabasepath variable indicates the directory where the data and log files are stored after the successful installation of the AdventureWorks database, and you can use the default values. No modification is required; thesqlsamplessourcedatapath variable indicates where the CSV file is stored. the value of two variables remember not to omit the trailing slash.

After you have set up two variables, you need to delete the previous comment.

3. Open the Command Prompt window and execute the command:

Sqlcmd-s (local)-e-i "C:\AdventureWorks 2008r2\adventureworks 2008R2 Data warehouse\instawdwdb.sql"

4. After the command is executed, open SQL Server Management Studioand you will see the adventureworks2008r2 database.

Installing the Adventure Works R2 sample Database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.