Can we create clustered index on non primary key column

Answer Posted / selvaraj.v

No, Because Constraints must have integrity. These are,
Clustered and Non-Clustered. So, to use Primary key with
any one Clustered or Non-Clustered index.

Example in SQL Server 2000:
Query :
-------
create table BookDetails
(
Book_ID int identity(1,1) not null clustered,
Book_Title varchar(20),
Book_Type varchar(15),
Book_Author varchar(25),
Book_Edition float,
Book_Publisher varchar(20),
Book_Pub_Year datetime,
Book_Price int
)

Answer:
-------
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'clustered'.

Prevent this Error To use Clustered Primary Key:
------------------------------------------------
Query In SQL Server 2000:
-------------------------

create table BookDetails
(
Book_ID int identity(1,1) not null primary key clustered,
Book_Title varchar(20),
Book_Type varchar(15),
Book_Author varchar(25),
Book_Edition float,
Book_Publisher varchar(20),
Book_Pub_Year datetime,
Book_Price int
)

Answer:
-------
The command(s) completed successfully.

Is This Answer Correct ?    4 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain Geography datatype in SQL Server

605


What is the use of partition by in sql server?

485


What are data driven subscriptions?

77


Is it true that rules do not apply to data already existing in a database at the time the rule is created?

533


What is field with example?

492






how would you troubleshoot blocking? : Sql server database administration

502


Can the “if update (colname)” statement be used in a delete trigger?

535


Can you please differentiate between a primary key and a unique key?

512


What is the difference between insensitive and scroll cursor?

553


Explain the advantages of merge replication?

489


What is serializable?

638


What are number line correlation administrators will use while working with a subquery?

600


Find nth lowest salary or get nth lowest salary?

568


what is new philosophy for database devises for sql server 7.0? : Sql server database administration

493


What is an indexed view?

561