SQL Server 2005 drop column with constraints

后端 未结 13 995
一向
一向 2020-12-07 23:54

I have a column with a \"DEFAULT\" constraint. I\'d like to create a script that drops that column.

The problem is that it returns this error:

Msg 50         


        
13条回答
  •  执念已碎
    2020-12-08 00:30

    I believe explicitly dropping the constraints prior to dropping the column is a "cleaner" solution. This way, you don't drop constraints you may not be aware of. If the drop still fails, you know there are additional constraints remaining. I like being in control of exactly what is happening to my database.

    Plus, scripting the drops explicitly guarantees the script and hopefully the results to be repeatable in exactly the way you intend.

提交回复
热议问题