[ Home ]

Cover of SQL Cover of SQL Tricks Cover of SQL Short Course Cover of SQL Visual QuickStart Guide 3rd Edition

Creating the Sample Database in Microsoft SQL Server 2000

To create books in Microsoft SQL Server 2000:

  1. On the Windows desktop, choose Start > All Programs > Microsoft SQL Server > Enterprise Manager.

    SQL Server Enterprise Manager opens.

    SQL Server Enterprise Manager
  2. In the Details (left) pane, navigate to the Databases folder of the server you’re using.

    SQL Server Enterprise Manager displays a list of databases in the Details pane.

  3. Choose Tools > Wizards.

    The Select Wizard dialog box appears.

  4. Click the plus (+) next to Database to expand the section, select Create Database Wizard, and then click OK.

    The Create Database wizard guides you through the steps needed to create a database.

    Select Wizard dialog box
  5. Click Next to skip the Welcome page.

  6. On the Name the Database and Specify Its Location page, type books in the Database Name field.

    If you want to change the location of the database or transaction-log files, click a browse button to choose a new location. (For production databases, normally you’d store the database and its log files on different physical drives, but you can store everything on the same drive for the sample database.)

    Click Next.

    Name the Database and Specify Its Location page
  7. On the Name the Database Files page, accept the default database filename and initial size, and then click Next.

    Name the Database Files page
  8. On the Define the Database File Growth page, accept the default database file-growth settings, and then click Next.

    For the sample database, let SQL Server increase the size of the database file automatically rather than only when you enlarge it explicitly.

    Define the Database File Growth page
  9. On the Name the Transaction Log Files page, accept the default transaction-log filename and initial size, and then click Next.

    Name the Transaction Log Files page
  10. On the Define the Transaction Log File Growth page, accept the default transaction-log-file growth settings, and then click Next.

    Define the Transaction Log File Growth page
  11. On the Completing the Create Database Wizard page, click Finish to accept your choices.

    Completing the Create Database Wizard page
  12. Click OK in the message box that appears after SQL Server creates the database successfully.

  13. In the next message box that appears, click No to decline creating a maintenance plan.

    The database books now appears in the Details pane of Enterprise Manager (under Databases).

  14. On the Windows desktop, choose Start > All Programs > Microsoft SQL Server > Query Analyzer.

  15. In the Connect to SQL Server dialog box, select the server and authentication mode, and then click OK.

  16. On the toolbar (near the top edge of the window), select the database books in the drop-down list.

  17. Choose File > Open (or press Ctrl+Shift+P), navigate to and select the file books_sqlserver.sql, and then click Open.

    The file’s contents appear in the Query window.

  18. Choose Query > Execute (or press F5).

    SQL Query Analyzer displays the results in the bottom pane. Ignore the messages about nonexistent tables — they’re caused by the script’s DROP TABLE statements, which you’ll need to rerun books_sqlserver.sql later to restore the tables to their original states.

    SQL Query Analyzer
  19. To run SQL scripts and interactive statements against books, see “Microsoft SQL Server” in Chapter 1 of SQL or SQL Tricks, or in Appendix B of SQL Short Course or SQL Crash Course for Beginners.

Tip