SQL Server 2008 is telling me to include the Primary Key in an index in the Included Column field. I thought the PK was automagically returned with all indexes?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No – not the primary key – the clustering key is.
By default, that’s the same in SQL Server – but it doesn’t have to be. It could well be that in this table, the PK is different from the clustering key. In that case, the index won’t have any knowledge of the PK.
The primary key is a logical construct to uniquely and clearly identify each row in your table. You use it for FK constraints etc.
The clustering key on the other hand is the physical index – it’s the “street address” or the page number where your actual, physical data is stored. Because of that, it’s included in each and every non-clustered index of that same table – it serves to lookup the actual data row, once you have found an entry in a non-clustered index.
UPDATE: okay, so I couldn’t resist asking “The Queen of Indexing”, Kimberly Tripp, about what she thinks on this topic – here’s her answer:
Does that help?