Can not ALTER COLUMN if it is used in INDEX, STATISTICS, PRIMARY KEY

If I change a column to not nullable or shorten a column, I get the error:

The altered column cannot be:

A column with a text, image, ntext, or timestamp data type.

The ROWGUIDCOL for the table.

A computed column or used in a computed column.

A replicated column.

Used in an index, unless the column is a varchar, nvarchar, or varbinary
data type, the data type is not changed, and the new size is equal to
or larger than the old size.

Used in statistics generated by the CREATE STATISTICS statement. First
remove the statistics using the DROP STATISTICS statement. Statistics
automatically generated by the query optimizer are automatically dropped
by ALTER COLUMN.

Used in a PRIMARY KEY or [FOREIGN KEY] REFERENCES constraint.

Used in a CHECK or UNIQUE constraint, except that altering the length of
a variable-length column used in a CHECK or UNIQUE constraint is
allowed.

Leave a Reply

You must be logged in to post a comment.