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
Explain atomicity?
Can you explain what is indexed view? How to create it?
Explain contrast amongst grouped and non-bunched records?
When to use Inner join & when to use subquery?
What is simple indexing method?
Tell me about pre-defined functions of sql?
in a table is b in column k (manikanta,sivananda,muralidhar) i want result like (mnikanta,sivnanda,murlidhar) please slove it
What are the advantages of paper records?
Can we perform backup restore operation on tempdb?
Explain what is it unwise to create wide clustered index keys?
What is the default order of an order by clause?
What is self contained sub query?
What objects does the fn_my_permissions function reports on? : sql server security
List out the differences between global and local temp tables in sql server?
How to convert a table data in XML format in sql server?