Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > CREATE TABLE VarcharNonClustered > ( > ID INT > ,Name VARCHAR(2000) > ) > GO > > <pre> > ✓ > </pre> <!-- --> > CREATE NONCLUSTERED INDEX idx_VarcharNonClustered_Name ON VarcharNonClustered(Name) > GO > > <pre> Warning! The maximum key length for a nonclustered index is 1700 bytes. The index 'idx_VarcharNonClustered_Name' has maximum length of 2000 bytes. For some combination of large values, the insert/update operation will fail. > </pre> <!-- --> > INSERT INTO VarcharNonClustered > VALUES (1,REPLICATE('a',1701)) > GO > > <pre> > Msg 1946 Level 16 State 3 Line 1 Operation failed. The index entry of length 1701 bytes for the index 'idx_VarcharNonClustered_Name' exceeds the maximum length of 1700 bytes for nonclustered indexes. > </pre> <!-- --> > INSERT INTO VarcharNonClustered > VALUES (1,REPLICATE('a',1700)) > GO > > <pre> 1 rows affected > </pre> <!-- --> > INSERT INTO VarcharNonClustered > VALUES (1,REPLICATE('a',901)) > GO > > <pre> 1 rows affected > </pre> <!-- --> > INSERT INTO VarcharNonClustered > VALUES (1,REPLICATE('a',900)) > GO > > <pre> 1 rows affected > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=sqlserver_2016&fiddle=36bab571665567b5d6b463dc7b1a18be)*
back to fiddle