SQL 3rd cover

SQL: Visual QuickStart Guide, Third Edition

Creating the Sample Database - Microsoft SQL Server 2005 Express Edition

To create books in Microsoft SQL Server 2005 Express Edition:

  1. On the Windows desktop, choose Start > All Programs > Microsoft SQL Server 2005 > SQL Server Management Studio Express.

    Microsoft SQL Server Management Studio Express opens.

  2. In the Connect to Server dialog box, select the server and authentication mode; then click Connect.

    Connect to Server
  3. In Object Explorer (the left pane), navigate to the Databases folder of the server that you're using.

    If Object Explorer isn't visible, choose View > Object Explorer (or press F8).

  4. Right-click the Databases folder and choose New Database.

    The New Database dialog box opens.

    New Database
  5. On the General page, type books in the Database Name field; then click OK. (You can use the General, Options, and Filegroups pages to specify other database settings, but the default settings work fine for the sample database.)

    SQL Server creates the database books and closes the New Database dialog box.

    General page
  6. In Object Explorer, expand the Databases folder and select the database books.

    New Query
  7. Choose File > Open > File (or press Ctrl+O); navigate to and select the file books_sqlserver.sql; then click Open.

    The file's contents appear in a new tab in the right pane.

    SQL query file contents
  8. Choose Query > Execute (or press F5).

    SQL Server Management Studio Express 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 results
  9. To run SQL scripts and interactive statements against books, see "Microsoft SQL Server" in Chapter 1.

Tip