Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more: , +
Can we delete clusterd index on primary key....can we add non clustered index on primary key
Posted

You can for example drop the clustered primary key and then create the primary key with NONCLUSTERED definition. For example:
SQL
ALTER TABLE MyTable ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED (MyKey);


See: ALTER TABLE[^] and table_constraint[^]
 
Share this answer
 
v3
Yes, You can do but you primary key constraint will also be deleted.

And yes you can have the non clustered index on primary key.

You can use below

SQL
alter table dbo.Table drop constraint pk_id

alter table dbo.Table add constraint pk_id primary key nonclustered (id)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900