DBAtlas · Database operations atlas

4922: ALTER TABLE ALTER COLUMN failed because one or more objects access this column

SQL Server

What does it mean?

You tried to change a column's type/property, but objects depending on that column (index, constraint, computed column, statistics, schema-bound view, etc.) prevented it. The column cannot be altered until the dependencies are removed.

Why does it happen?

The column is used in an index, a PRIMARY KEY/UNIQUE/CHECK/DEFAULT constraint, a computed column expression, a view/function defined WITH SCHEMABINDING, or a statistics object. A type/size change would invalidate those objects, so the ALTER is rejected.

How to fix it

First find the dependent objects and temporarily drop or disable them, alter the column, then recreate them. Query sys.sql_expression_dependencies and sys.indexes/sys.default_constraints to see the dependencies. Typical order: DROP CONSTRAINT/INDEX -> ALTER COLUMN -> CREATE again. For schema-bound views, temporarily remove SCHEMABINDING and add it back.

Open in DBAtlas →

More from this engine