So really, how many clustered indexes can I create on a table?

Published On: 2009-03-26By:

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.

Denny


Contact the Author | Contact DCAC

Video

Globally Recognized Expertise

As Microsoft MVP’s and Partners as well as VMware experts, we are summoned by companies all over the world to fine-tune and problem-solve the most difficult architecture, infrastructure and network challenges.

And sometimes we’re asked to share what we did, at events like Microsoft’s PASS Summit 2015.

Awards & Certifications

Microsoft Partner    Microsoft MVP    Microsoft Certified Master    VMWare Partner    VMWare vExpert
   Best Full-Service Cloud Technology Consulting Company    Insights Sccess Award    Technology Headlines Award    Golden Bridge Gold Award    CIO Review Top 20 Azure Solutions Providers
Share via
Copy link