Quick steps: Creating a nonclustered index in code

Learn to create a nonclustered index in code using Query Analyzer in this book excerpt from MCAD/MCSD/MCSE Training Guide (70-229): SQL Server 2000 Database Design and Implementation.

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.3

Creating a nonclustered index in 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
    CREATE TABLE IndexPractice2
    ( Student_ID char(32) NULL,
    Height integer NULL,
    Weight integer NULL )
    

  3. After creating a new table, create a new clustered index as shown in Figure 10.4. To do this, code in the following:
    Use Pubs
    CREATE CLUSTERED INDEX Weig
  4. ht_index ON IndexPractice2 (Weight)
  5. To see your new index, open the Query Analyzer, expand the Pubs database in the Object Browser, and then expand User Tables. Expand IndexPractice2, and then expand Indexes. If you followed the steps properly, you should see Weight_index listed underneath Indexes. If you still have Query Analyzer open, you may need to right-click User Tables under the Pubs database and choose Refresh before the new table will appear.


Click for the complete book excerpt series.

This was first published in January 2006

Dig deeper on SQL Server Database Modeling and Design

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close