FIX: Cannot create compressed nonclustered index on a table that has a clustered index with two or more bit columns

Applies to: SQL Server 2008 R2 Service Pack 2SQL Server 2008 R2 DeveloperSQL Server 2008 R2 Enterprise

Symptoms


Consider the following scenario:
  • You have a table that has two or more bit data type columns in Microsoft SQL Server 2008 R2.
  • You create a clustered index that contains two or more bit data type columns on the table.
  • You create a nonclustered index on any column and specify the DATA_COMPRESSION option.
In this situation, you receive the following error:
Msg 1944, Level 16, State 1, Line <Line Number>

Index '<Index Name>' was not created. This index has a key length of at least -<Length> bytes. The maximum permissible key length is <Length> bytes.

Cause


The issue occurs because the space requirements of bit data type columns are calculated incorrectly in this scenario.

Resolution


The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 13 for SQL Server 2008 R2 SP2

Workaround


To work around this issue, change the data type of the columns from bit to tinyint.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.