4922: ALTER TABLE ALTER COLUMN failed because one or more objects access this column
SQL ServerWhat 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.
More from this engine
- 15023User already exists in the current database
- 18452Login failed. The login is from an untrusted domain and cannot be used with Windows authentication
- 605Attempt to fetch logical page belongs to a different allocation unit
- 7202Could not find server 'name' in sys.servers
- 40501The service is currently busy. Retry the request after 10 seconds
- 8645A time out occurred while waiting for memory resources to execute the query
- 8651Could not perform the operation because the requested memory grant was not available