See below DDL:
CREATE TABLE Person
(
ID int identity not null,
Name VARCHAR(100),
Age int,
EyeColour varchar(20),
primary key (ID)
)
CREATE INDEX Name ON Person (Name)
CREATE INDEX Age ON Person (Age)
CREATE INDEX EyeColour ON Person (EyeColour)
I can fulfill the following statement:
ALTER TABLE person
ALTER COLUMN name VARCHAR(110)
However, I cannot fulfill the following statement:
ALTER TABLE person
ALTER COLUMN name VARCHAR(90)
Mistake:
Msg 5074, Level 16, State 1, Line 1
The index "Name" depends on the name of the column.
Msg 4922, level 16, state 9, line 1
ALTER TABLE ALTER COLUMN name failed because one or more objects are accessing this column.
Why do I see these errors when I reduce the length VARCHAR. In what other scenarios will I see this error, for example. change data type?
Is there an automated way to determine all the indices and restrictions associated with changing the data type and processing it?