SQL Server 2005 drop column with constraints
Posted
by Julien N
on Stack Overflow
See other posts from Stack Overflow
or by Julien N
Published on 2008-11-24T18:36:30Z
Indexed on
2010/04/21
18:03 UTC
Read the original article
Hit count: 273
sql-server
|sql-server-2005
Hi !
In Sql Server 2005 I have a column with a "DEFAULT" constraint. I'd like to create a script that drops that column.
The problem is that is returns me that error :
Msg 5074, Level 16, State 1, Line 1
The object 'DF__PeriodSce__IsClo__4BCC3ABA' is dependent on column 'IsClosed'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE DROP COLUMN IsClosed failed because one or more objects access this column.
I couldn't find an easy way to drop a column and all its associated constraints (only found big scripts that look into system table... there MUST (!!) be a "nice" way to do that !).
And as the DEFAULT constraint's name has been randomly generated, I can't drop it by name.
Thanks for your help.
© Stack Overflow or respective owner