tags:

views:

246

answers:

5

Is there any way by which i can add more than 16 columns in clustered index.

+6  A: 

As of SQLserver 2008 , no. However , I suspect the bottleneck is somewhere else if you require a clustered index on more than 16 columns.

Learning
+2  A: 

No. further, you are limited to a total of 900 bytes of data for the combined key size.

Quoting from the Create Index reference page.

Up to 16 columns can be combined into a single composite index key. All the columns in a composite index key must be in the same table or view. The maximum allowable size of the combined index values is 900 bytes. For more information about variable type columns in composite indexes, see the Remarks section.

tvanfosson
+1  A: 

The 16 columns maximum in a clustered index can only by overcome by pure and total madness. The kind where you are locked away from a computer forever, never allowed to attempt things like this.

Therefore, it is not possible.

ck
I can understand why you were downvoted, but also understand your sentiment you should re word in a less offensive way
Sam Saffron
ok fair enough'; create table humour (id1 int); --
ck
A: 

As others have noted this isn't possible, or even desirable. Clustered indexes are not a good choice for wide keys because:

the key values from the clustered index are used by all non-clustered indexes as lookup keys. Any non-clustered indexes defined on the same table will be significantly larger because the non-clustered index entries contain the clustering key and also the key columns defined for that non-clustered index.

If you're happy with non-clustered indexes, then as of SQL Server 2005 and above you can use Included Columns to overcome the 900 byte, 16 column limits.

ninesided
A: 

No, 16 is the limit.

But you can combine the keys into one hash value. this should raise the speed. ofcurse the hash values should be indexed.

Bernd Ott