This used to be a very easy question to answer as the answer was 1. However these days, with some creativity you can get some extra ones.

The basic definition of a clustered index is that it has one or more indexed columns, and all other columns are added to the index as non-indexed columns.

Until SQL Server 2005 we didn’t have the ability to add additional columns to the index without sorting them. SQL Server 2005 introduced us to the concept of included columns.

So technically you can still only have 1 clustered index per table (an index created with the keyword CLUSTERED in the CREATE INDEX statement). But you can create as many nonclustered indexes as you need (up to the 999 nonclustered indexes per table that you are allowed) and as long as you include every other column in the database the index will effectively function like a clustered index.

Thanks to Erland and Hugo for the interesting discussion at PASS last November which prompted this post, not to mention letting me hang out with them for a few hours and pick their brains.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

There was an error processing your information. Please try again later.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

About This Blog

Interesting tidbits about Microsoft SQL Server (and lots of other stuff about IT) that will help you build a rock solid database server and keep it running for many years to come.