Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dropping a column with Dependencies

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2002-07-28 : 18:02:24

ALTER TABLE Users DROP COLUMN EmployeeType

Returns

ALTER TABLE DROP COLUMN EmployeeType failed because one or more objects access this column.

So, there's a dependency created by the DEFAULT '' On this field.

I've checked BOL, and other than explicitly DROPing the Dependency, is there a more direct way to drop this column?

SamC

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-28 : 18:04:45
Nope. You need to drop the constraint(s) and foreign key(s) on the column first.

Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2002-07-28 : 18:14:38
This get's messy then.

BOL is vague about this.

Is there a way to remove the dependency without explicitly naming it like:

ALTER TABLE Users ALTER COLUMN EmployeeType NODEFAULT

To kill the default value to the column, then delete the column with

ALTER TABLE Users DROP COLUMN EmployeeType??

SamC



Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-28 : 18:23:34
You'd have to use dynamic SQL to do it.

Go to Top of Page
   

- Advertisement -