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 having clause and where clause?
How to convert numeric values to integers in ms sql server?
What is explicit mode in sql server?
What is sql server schema compare? How we can compare two database schemas?
Mention the differences between local and global temporary tables.
What are the 7 disadvantages to a manual system?
How many cores do I need for sql server 2016?
User wants only to display only pdf as export option in report manager. How to achieve this?
Explain trigger and its types?
What is temporal data type?
How to change the system date and time from SQL Plus Terminal ?
How do you rebuild an identity column?
Explain transaction isolation levels in sql server?
How to count groups returned with the group by clause in ms sql server?
How to concatenate two strings in SQL Server.