ALTER COLUMN when table depends on the column

4.2k views Asked by At

I'm trying to alter a column type to increase its size but SQL gives me the following message

Msg 5074, Level 16, State 1, Line 1
The object 'table_name' is dependent on column 'column_name'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN column_name failed because one or more objects access this column.

when I run this query

ALTER TABLE table_name ALTER COLUMN column_name VARCHAR (25) NULL;

The questions that I found about this problem are either a constraint or a statistic that holds you from updating the column, but here the own table is dependant on the column that I want to edit.

And the column is not used as FK or anything like that.

How can I change the column type?

3

There are 3 answers

2
Milney On

One possibility is that there is a Computed or Calculated Column in the table whose expression is based on this column? Removing that would solve the issue.

Please post the full DDL for the table in order for us to actually help

0
Vinoth Raj On
ALTER TABLE <schemaName>.<tableName>
ALTER COLUMN <columnName> nvarchar(200) [NULL|NOT NULL]

Note :Don't forget the Null....

0
Luiz Eduardo Simões On

Turns out it was the Full-Text Index that was creating this dependency on the column. Had to completely remove the Full-Text Index, edit the column and rebuild it.