Walkthrough: Install the adventureworks Database

Source: Internet
Author: User
Tags sql server express

Post: http://msdn.microsoft.com/zh-cn/library/aa992075 (loband). aspx
Download

In learning sql2005, you cannot leave the sql2005 sample database. You can download and install the adventureworks database, download and install the northwind database, and download and install the pubs database. The three libraries of adventureworks, northwind and pubs on Microsoft are hard to find and e-mapreduce is easy to use today.
Download the SQL 2005 sample library. After decompression, there are two folders: adventureworks and northwind.

How to install and use the adventureworks database:

There is an adventureworksdb. MSI file under the adventureworks folder. Double-click to install.
Then attach the database to SQL 2005. The location of adventureworksdb. DBF is:
C: \ Program Files \ Microsoft SQL Server \ mssql.1 \ MSSQL \ data \ adventureworks_data.mdf
Install My SQL 2005 on c: \ Program Files \ (that is, the default installation path for installing SQL 2005)
In this step, the installation of adventureworks is complete.

How to install and use the northwind database and pubs database:

The file sql2000sampledb. MSI is located under the northwind folder. Double-click to install.
Default installation path: C: \ SQL Server 2000 sample Databases
It includes the SQL script files of the northwind database, pubs database, northwind database, and pubs database.
You can choose to run the query or additional database. Cngothic adopts the additional method. Attach two databases to SQL.
This ends.

This walkthrough demonstrates how to install SQL Server 2005AdventureworksSample Database, which is required to perform other drills in the reportviewer document.AdventureworksIt is not automatically installed with SQL Server or SQL Server Express, but can be downloaded from the Microsoft website. You can use the instructions provided in this walkthrough to download and installAdventureworksDatabase and configure its connection.

Distributed along with SQL Server 2005AdventureworksVersion andAdventureworksEarlier versions are different. Therefore, even if you have installed an earlier version of adventureworks, you must install the latest version to make the queries in other reportviewer rehearsals run properly.

To learn more aboutAdventureworksFor more information about the sample database, you can search "adventureworks example OLTP Database" in SQL Server 2005 books online ". Most versions of Visual Studio 2008 provide books online. You can also view it in msdn that is located on the http://www.microsoft.com. You can also download adventureworks OLTP database digraphs from the http://www.microsoft.com/downloads ).

Required

You must install an SQL server instance and have relevant permissions on it. If SQL Server 2005 Express is installed, the default Instance name is(Local) \ sqlexpress. If you want to upgrade an MSDE instance to SQL Server 2005 Express, see the SQL Server online series topic "upgrade MSDE to SQL Server Express ".

The following steps describe how to download, save, attach, and configureAdventureworksDatabase.

Download adventureworksdb. MSI

  1. Navigate to the Microsoft website that provides download. Double-click adventureworksdb. MSI.

  2. Click"Run"Complete the installation wizard. Adventureworks_data.mdf and adventureworks_log.ldf will be copied to the SQL server data directory. For SQL Server 2005 Express, the default directory is c: \ Program Files \ Microsoft SQL Server \ mssql.1 \ MSSQL \ data \.

Check the SQL server data directory

  1. Open a Visual Studio 2008 command window. For this reason, go"Start"Click"All Programs","Microsoft Visual Studio 2008","Visual Studio Tools"And"Visual Studio 2008 command prompt".

  2. In the command line, type or copy the following command to open the connection to the local SQL Server express instance:

    SQLCMD -S (local)\sqlexpress -E

  3. Press"Enter".

  4. At the sqlcmd prompt, type or copy the following command.

    select physical_name from sys.database_files where name = 'master'go

    This query will return the location of the master. MDF file to confirm that it will be placedAdventureworksThe SQL Server Data Directory of the database file.

Attach adventureworks to SQL Server

  1. In"Sqlcmd 1>"At the prompt, callSp_attach_dbStored Procedures to appendAdventureworksDatabase. The following code uses the default location of SQL Server 2005 Express. Edit the text as needed to use the data directory confirmed in the preceding steps. In the command window, type the following statement, or copy the statement and paste it in the Command window (the statement cannot contain line breaks ).

    exec sp_attach_db @dbname=N'AdventureWorks', @filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf'

  2. TypeGo.

  3. Press enter. You may see a series of messages about database conversion and upgrade.

  4. Type"Exit"Close the command window.

Verify that adventureworks has been attached

  1. Open Visual Studio 2008. You do not need to open a project.

  2. Slave"View"Select"Server resource manager".

  3. In"Server resource manager"Window, right-click"Data Connection"And then select"Add connection". It will be opened immediately"Add connection"Dialog box.

  4. Confirm"Data Source"Set"Microsoft SQL Server (sqlclient )".

  5. In"Server name"Enter (local) \ sqlexpress in the text box.

  6. In"Log on to the server"Select your authentication method.

  7. In"Select or enter a database name"To expand the database list.

  8. Select "adventureworks" .

  9. Click"Test connection"To verify that the connection to adventureworks is successful.

Note:

After the connection is established, if you want to query the data source, right-click the data connection icon of adventureworks and select"New query"To call"Query expression"Window.

Configure adventureworks to use web server controls

  1. Open a Visual Studio 2008 command window to run sqlcmd. You will use sqlcmd to grant access permissions to databases and ASP. NET accounts.

    On Windows Server 2003, ASP. NET processes used by web server controls run under nt authority \ Network Service. On other Windows operating systems, this process runs under machinename \ ASPnet.

    If SQL Server express 2005 is installed, type or copy the following sqlcmd to grant the service logon permission. Otherwise, you must specify"(Local) \ sqlexpress"SQL Server instance.

    The following example applies to Windows Server 2003 and does not contain line breaks.

    sqlcmd -E -S (local)\sqlexpress -Q "sp_grantlogin N'NT AUTHORITY\NETWORK SERVICE'"

  2. To grant access to adventureworks for this service, use the following command (cannot contain line breaks ).

    sqlcmd -E -S (local)\sqlexpress -d AdventureWorks -Q "sp_grantdbaccess N'NT AUTHORITY\NETWORK SERVICE'"

  3. To add this serviceAdventureworksIn the owner role account, use the following command (cannot contain line breaks ).

    sqlcmd -E -S (local)\sqlexpress -d AdventureWorks -Q "sp_addrolemember 'db_owner', N'NT AUTHORITY\NETWORK SERVICE'"

  4. Close the command window.

  5. If the drill can be completed successfully: in local processing mode, use the database data source with the reportviewer Web Server Control to confirm that the configuration is correct.

Subsequent steps

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.