Msg 1904, Level 16, State 1, Line 1
The %S_MSG ‘%.*ls’ on table ‘%.*ls’ has %d column names in %S_MSG key list. The maximum limit for index or statistics key column list is %d.
This error message appears when you try to create an index or a constraint with more than 16 columns.
The T-SQL statement can be parsed, but causes the error at runtime.
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. The maximum number of column in an index or a constraint in SQL Server is 16.
All versions of SQL Server
IF OBJECT_ID(‘tempdb..#t’) > 0
DROP TABLE #t
CREATE TABLE #t
ALTER TABLE #t
ADD CONSTRAINT PK_t PRIMARY KEY
In the above example we try to create a PRIMARY KEY constraint with more than 16 columns. This raises the error.