Can we create clustered index on non primary key column

Answer Posted / vamsi krishna

Create table Testing(testingID int,testingdesc varchar(20))
Note: I am not defining TestingID as primaryKey
create clustered index IX_TestingID on Testing(TestingID)
-- This will allow u to insert duplicate values to the
column that has clustered index created.

Instead run the below command to create unique Clustered
Index
create unique clustered index IX_TestingID on Testing
(TestingID)

-- The above statment will not allow u to add duplicate
records.
For your better conformation insert some records into the
tabel and execute a select statement having the clustered
index column in the where clause and check the execution
plan. You can see Index Seek.

Conclusion : Clustered index can be created on non
primaryKey column

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many full-text indexes can a table have?

720


How do I know if localdb is running?

693


What is the difference between system objects and user objects?

884


What is pivot and unpivot?

776


What is the difference between function and stored procedure in sql server?

679






what is unique and xaml nonclustered index

777


How to handle error or exception in sql?

703


What are 3 ways to get a count of the number of records in a table?

826


You want to implement the one-to-many relationship while designing tables. How would you do it?

709


can we have a nested transaction? : Sql server database administration

697


Explain about extended stored procedure?

677


how to restart sql server in single user mode? How to start sql server in minimal configuration mode? : Sql server database administration

662


what are acid properties? : Sql server database administration

668


How to transfer data from a cursor to variables with a "fetch" statement?

767


Define msdb database?

785