Can we create a clustered index on composite primary key.

Answer Posted / anil kumar

Here's the procedure:

Create a table with no primary key defined.
Create clustered index on the primary key columns.
Alter the table to define the primary key.

Table creation:

create table CDSWEB.Anil (officeid integer not null,
empid integer not null,
age integer ,sex varchar(5),
name varchar(20));

Index creation:
create index CDSWEB.AN001 on CDSWEB.Anil(officeid,empid)
CLUSTER;

Primary key defined:

alter table CDSWEB.ANIL
add primary key (officeid,empid);

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In which format does an image save in SQL Server database ?

580


How do I find information about the install locations for the various instances running on a computer?

545


Do you know what is user defined datatypes and when you should go for them?

490


What are the different authentication modes in sql server?

557


How to locate and take substrings with charindex() and substring() functions?

500






Tell me extended events in sql server 2008?

547


How to create a dml trigger using create trigger statements?

549


What is an example of a foreign key?

499


What happens if null values are involved in arithmetic operations?

574


What is the use of commit?

530


Explain candidate key, alternate key, and composite key?

579


What does it mean if @@cursor_row returns a negative number?

564


Explain how to integrate the ssrs reports in application?

515


What is the meaning of sql server?

520


Can we join two tables without primary key?

604