Can we create clustered index on non primary key column

Answer Posted / suraj

-- YES.

drop table Employees
create table Employees(
EmpID int Primary Key NonClustered,
[Name] varchar(20),
SSNo varchar(20) )

CREATE CLUSTERED INDEX ci_EMPLOYEES_SS ON EMPLOYEES (Name)

insert Employees values (101,'John','123-45-6789')
insert Employees values (102,'Mike','123-45-6789')


select * from Employees

-- We have to specifically define NonClustered in the
Primary Key column because Clustered Index is created by
default in Primary Key.
-- And, We are able to define Clustered Index in
another column because every table is eligible to have one
clustered index.
-- Clustered Index has to be created after table
creation.
-- From above example, EmpID doesn't take duplicates,
because it is primary key. But, SSNo takes duplicates.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what does the automatic recovery do? : Sql server administration

540


What will happen if a column containing char type data is changed to the nchar data type?

627


How do I start sql server 2016?

525


How the authentication mode can be changed?

608


How do I run a trace in sql server?

505






What is the difference between set and select?

581


What is the use of keyword with encryption.

583


Tell me what is normalization? Explain different forms of normalization?

550


Explain the different types of backups available in sql server? : sql server database administration

521


how would you store your query in an SSRS report or a Database server?

118


In case you have filters in your report, when filters will be applied in cached report instance?

81


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

564


Explain the difference between HTTP and HTTPS in database?

564


Describe how to use the linked server?

606


Can you create a logon trigger in sql server 2005 express edition?

576