15.2. Sample Database

For this chapter and the example walkthroughs, we looked at the various sample databases available; and after playing with most of them we decided that a simpler case would work just as well, be easier for readers to reproduce in their own environment, and be simpler to use to illustrate how each feature works.

Open the SQL Server solution file People.ssmssln under the downloads folder for this chapter on the book's website at www.wrox.com.

You can either build the People database using following steps or restore the People database from the backup file People.bak provided in the People folder. To build the People database:

  1. Open the script 1_CreateDatabase.sql. The FILENAME option in the CREATE DATABASE statement has the path C:\mssql\Data. Make sure that you create these folders before running the script or adjust it to the correct path according to your system. Now run the script 1_CreateDatabase.sql.

  2. Open the script 2_CreateTables.sql and run it. This script will create four tables: People, BoysNames, GirlsNames, and LastNames.

  3. Open the script 3_MakeNames.sql and run it. This script creates the stored procedure MakeNames, which is used in the next step to populate some data. This procedure has two arguments. The first is the number of names to insert (the default is 100). The second indicates which type of name to insert: a male name ("B" for Boys), a female name ("G" for Girls), or the default, a last name ("L" for LastNames).

  4. Open the script 4_Exec_MakeNames.sql ...

Get Professional Microsoft® SQL Server® 2008 Administration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.