SQL Server error 5074: Object is dependent on column
ALTER TABLE couldn't drop or change a column because an index, constraint, statistic or computed column depends on it. Drop that object first.
- Error number
5074- Severity
- 16
- Category
- Names and objects
What it means
SQL Server won't drop or alter a column while other objects rely on it. Error 5074 names the dependent object, such as a default constraint, an index or a statistics object. It is usually followed by 4922, which reports that the ALTER TABLE failed.
Common causes
- A default constraint on the column (they are created automatically with system-generated names when you use
DEFAULT). - An index, unique constraint, foreign key or statistics object that includes the column.
- A computed column or a schema-bound view that references it.
How to fix it
-
Find default constraints on the column.
SELECT dc.name FROM sys.default_constraints AS dc JOIN sys.columns AS c ON c.object_id = dc.parent_object_id AND c.column_id = dc.parent_column_id WHERE dc.parent_object_id = OBJECT_ID(N'dbo.Orders') AND c.name = N'Status';
-
Drop the dependent object named in the message, then alter the column.
ALTER TABLE dbo.Orders DROP CONSTRAINT DF__Orders__Status__1A2B3C4D; ALTER TABLE dbo.Orders DROP COLUMN Status;
-
Name default constraints explicitly when you create them, so scripts don't depend on generated names.
Related errors
4922Objects access this column3726Can't drop: referenced by a FOREIGN KEY2BP01PostgreSQL: dependent objects still exist
More names and objects errors
208Invalid object name207Invalid column name4104Multi-part identifier not bound209Ambiguous column name2812Could not find stored procedure2714There is already an object named3701Cannot drop, object not found3702Cannot drop database, currently in use
The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.
Work on SQL Server in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.