Pages

Thursday, November 24, 2011

Resouces For Sql Server:Install adventureworks Database

The VS.net 2008 Beta 2 was released one month ago. After downloading the virtual machine, I decided to install the AdventureWorks sample database on the SQL Express. The main reason to choose SQL Express is because the VS 2008 Beta2 virtual machine already installed SQL Express. Here is a list of steps I followed to install Adventure Works databases.
  1. Check SQL Express and ensure it’s up and running.
    Open a DOS prompt, and type net start “SQL Server (SQLExpress)”. If you get warning message, “the requested service has already been started”, then the SQL Express is running.

     
  2. Configure/verify SQL Express to accept remote connections
    3.1 Enable TCP/IP
    By default, the TCP/IP and Named Pipes protocols are disabled.

    Launch the SQL Server Configuration Manager from SQL Server 2005 | Configuration Tools | SQL Server Configuration Manager

    Click SQL Server 2005 Network Configuration | Protocols for SQL Express, right click TCP/IP and enable it.

    3.2 Enable SQL Browser service. If you don’t enable this service, you need to specify the TCP port in your connection string.

    Administrative Tools | Services | SQL Server Browser

    3.3 In the DOS prompt, type sqlcmd -S .\SQLExpress, if you get “>” sign, cool! It works.

    3.4 type “select @@version”, then enter, type “go”, then enter, you should see the result message which indicates that you can connect to your SQL Express without issues now.
  3. Download and install Adventure Works database
    Browse to http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004 and click AdventureWorksDB.msi
    Once the download is completed, you can start to install it by following the installation screen instruction. The database files will be installed at c:\Program files\microsoft sql server\mssql.1\mssql\data folder. The installation just places the database files in this folder, you still to attach it into the SQL Express.
  4. Attach database.
    Once connect to the SQL Express, type the following commands:

      USE [master]

    GO

    CREATE DATABASE [AdventureWorks] ON

    ( FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf’ ),

    ( FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Log.ldf’ )

    FOR ATTACH ;

    GO

     
  5. You can verify database by typing the following commands:

     select name from sys.databases
    Go


    If you see the AdventureWorks in the list, then database is attached successfully.


    Alternatively, you can verify the AdventureWorks database by launching VS 2008 beta 2, then click View | Server Explore, right click on the Data Connections, then click Add connection. In the Choose Data Source window, choose SQL Server, then click Next. In the Add Connection window, enter .\SQLExpress as the Server name. Select the database name, AdventureWorks. Click Test Connection.

No comments:

Post a Comment