I need to be able create a unique constraint that checks that a string and integer combination is unique.
I have tried code:
ALTER TABLE mytable ADD CONSTRAINT
constraint_Unique_ForeignID_MyString UNIQUE NONCLUSTERED
(
foreign_id, my_string_col
)
But I get error:
Msg 1919, Level 16, State 1, Line 1
Column ‘my_string_col’ in table
‘my_string_tbl’ is of a type that is
invalid for use as a key column in an
index.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint.
See previous errors.
How can I create the constraint I need?
How BIG of a
VARCHARis your column??Any index can only contain columns up to a maximum of 900 bytes total. There is no way to get around this, or to increase that number to a higher value.