clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2591543 fiddles created (45741 in the last week).

CREATE TABLE VarcharNonClustered ( ID INT ,Name VARCHAR(2000) )
 hidden batch(es)


CREATE NONCLUSTERED INDEX idx_VarcharNonClustered_Name ON VarcharNonClustered(Name)
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.
 hidden batch(es)


INSERT INTO VarcharNonClustered VALUES (1,REPLICATE('a',1701))
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.
 hidden batch(es)


INSERT INTO VarcharNonClustered VALUES (1,REPLICATE('a',1700))
1 rows affected
 hidden batch(es)


INSERT INTO VarcharNonClustered VALUES (1,REPLICATE('a',901))
1 rows affected
 hidden batch(es)


INSERT INTO VarcharNonClustered VALUES (1,REPLICATE('a',900))
1 rows affected
 hidden batch(es)