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
Explain the phases a transaction has to undergo?
do you know how to configure db2 side of the application? : Sql server database administration
Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.
How to find index size for each index on table?
Do you know what is difference between stored procedure and user defined function?
What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?
What are the advantages of having an index on the sql server?
Explain indexed views and partitioned view with their syntax.
What is not null constraint?
What are differences in between sql server 2012 and sql server 2016?
What are the benefits of normalization?
What is the security principal at the server level that represents your session?
What happens when transaction log is full?
What is meant by datasource?
What is exporting and importing utility?