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
How do I view a procedure in sql server?
Difference between Logical Page and Physical Page in SSRS.
What are parameterized reports?
What are the transaction properties?
whats the maximum size of view state??
What stored by the model?
Do you know what is fill factor and pad index?
What are the restrictions while creating batches in sql server?
what types of replication are supported in sql server? : Sql server database administration
Explain the relational database management system (rdbms)?
What is named query? : sql server analysis services, ssas
What does the not null constraint do?
What is the difference between primary key and unique constraints?
What are the advantages of using cte?
What is sql server profiler trace data file?