SQL: Non-clustered indexes

When creating non-clustered indexes, you should never include the clustered index key fields (commonly used for the primary key) as part of the non-clustered index.

This is because the fields will always be used within queries.  There is no need to specify them again.

The only exception to this, would be if the clustered index key is made up of more than one field, and the non-clustered index is based on one part of the clustered index key.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.