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
Mention a few common trace flags used with sql server?
Is sql server a database?
What action plan is preferred if sql server is not responding?
Your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files?
How to write a query with a full outer join in ms sql server?
What is service broker? : sql server database administration
Does server sql treat char as a variable-length or fixed-length column?
List out the difference between union and union all in sql server?
explain extended properties
How to achieve Paging of records in SQL SERVER?
What is normalization of database? What are its benefits?
How to link tables in sql server?
What are the different index configurations a table can have?
is there a column to which a default can't be bound? : Sql server database administration
How to locate and take substrings with charindex() and substring() functions?