Quick steps: Creating a clustered index using code

The following excerpt, courtesy of Que Certification, is from Chapter 10 of the book MCAD/MCSD/MCSE Training Guide (70-229): SQL Server 2000 Database Design and Implementation by Thomas Moore and Ed Tittel. Click for the complete book excerpt series or purchase the book.



STEP BY STEP - 10.1

Creating a clustered index using code

  1. Open the Query Analyzer by selecting Query Analyzer from the Start menu.

  2. Create a new index on a new table. To do this, first create a new table in the Pubs database. In the code pane, type in the following:
    use Pubs
    go
    CREATE TABLE IndexPractice
    ( YourName char(32) NULL,
    Age integer NULL,
    BirthDate integer NULL )
    

  3. After creating a new table, create a new clustered index. To do this, code in the following:
    CREATE CLUSTERED INDEX age_index
    ON IndexPractice (age)
    

  4. To see your new index, open the Query Analyzer, expand the Pubs database in the Object Browser, and then expand User Tables. Expand IndexPractice and then expand Indexes. If you followed the steps properly, you should see age_index listed below Indexes.


Click for the complete book excerpt series.


This was first published in January 2006

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.