// SQL Server error reference

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
Error message
The %S_MSG '%.*ls' is dependent on %S_MSG '%.*ls'.

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

  1. 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';
  2. 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;
  3. Name default constraints explicitly when you create them, so scripts don't depend on generated names.

Related errors

More names and objects errors

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.

// fewer errors, faster fixes

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.