O'Reilly logo

SQL Server® 2008 Administration: Real World Skills for MCITP Certification and Beyond by Tom Carpenter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Basic Indexes

Now that you understand what indexes are, how they work, and the different types of indexes, it's time to start creating some indexes. The following sections will step you through creating both clustered and nonclustered indexes.

Creating a Clustered Index

You will now create a clustered index in the most common way—by creating a primary key. In order to perform the steps in Exercise 10.1, you must first create a table in the Books database with the following code:

CREATE TABLE dbo.Customers (
    CustomerID int NOT NULL,
    FirstName varchar(50),
    LastName varchar(50),
    eMail varchar(60),
    Phone int,
    City varchar(40),
    State char(2),
    ZipCode int
    );

You can enter and execute this code in a New Query window within SSMS. Ensure that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required