Translate

Wednesday 24 December 2014

How to create nonclustered index in Create Table?

The help in books online does in fact mention the keyword CLUSTERED, but it is only relevant for UNIQUE or PRIMARY KEY constraints. Both these constraints create an index, and you can specify if that index is to be clustered or non-clustered.

You cannot use that syntax to create a standard non clustered index.

Create table FavoriteDish  
(  
FavID int identity (1,1) primary key not null,  
DishID int references Dishes(DishID) not null ,  
CelebrityName nvarchar(100)   constraint ux_CelebrityName unique NONCLUSTERED not null    
)

No comments:

Post a Comment