|
SQL: Visual QuickStart Guide, Third EditionCreating the Sample Database - Microsoft SQL Server 2005 Express Edition |
To create books in Microsoft SQL Server 2005 Express Edition:
-
On the Windows desktop, choose Start > All Programs > Microsoft SQL Server 2005 > SQL Server Management Studio Express.
Microsoft SQL Server Management Studio Express opens.
-
In the Connect to Server dialog box, select the server and authentication mode; then click Connect.
-
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).
-
Right-click the Databases folder and choose New Database.
The New Database dialog box opens.
-
On the General page, type
booksin 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 databasebooksand closes the New Database dialog box.
-
In Object Explorer, expand the Databases folder and select the database
books.
-
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.
-
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'sDROPTABLEstatements, which you'll need to rerunbooks_sqlserver.sqllater to restore the tables to their original states.
-
To run SQL scripts and interactive statements against
books, see "Microsoft SQL Server" in Chapter 1.
Tip
-
The script
books_sqlserver.sqldiffers slightly from the standard SQL scriptbooks_standard.sql. In the SQL Server script, the data type of the columnpubdatein the tabletitlesisDATETIME(rather thanDATE). Also, date literals don't have theDATEkeyword. (The standard SQLDATE'2000-08-01', for example, is equivalent to the SQL Server date'2000-08-01'.)