use AdventureWorks2012 ;

---------------------------------------------------------------------------------
-- Abschnitt 9.9.1
create unique clustered index uq_wrk on wrkBikesAccessories
	( ProductID ) ;
go

alter table wrkBikesAccessories 
	add constraint PK_wrk primary key ( ProductID ) ;
go

drop index uq_wrk on wrkBikesAccessories ;
go

create index ix_wrk_Cat on 
	wrkBikesAccessories ( Category ) ;
go

create index ix_wrk_SubCat on 
	wrkBikesAccessories ( SubCategory ) ;
go

create index ix_wrk_Cat_SubCat on 
	wrkBikesAccessories ( Category, SubCategory )
	include ( Number ) ;
go

create unique index uq_wrk_Number on wrkBikesAccessories 
	( Number ) ;
go

drop index ix_wrk_Cat on wrkBikesAccessories ;
go

alter table wrkBikesAccessories 
	drop constraint PK_wrk ;
go

drop index ix_wrk_Cat on wrkBikesAccessories;
go

create index ix_wrk_Cat on wrkBikesAccessories  ( Category ) ;
go

alter table wrkBikesAccessories 
	add constraint PK_wrk primary key ( ProductID ) ;
go

alter index ix_wrk_Cat on wrkBikesAccessories
	reorganize ;
go

alter index ix_wrk_Cat on wrkBikesAccessories
	rebuild with ( statistics_norecompute = on ) ;
go

alter index ix_wrk_Cat on wrkBikesAccessories
	set ( statistics_norecompute = off ) ;	
go
