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 /en-us/help/2967540
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
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.