How to drop a column which is having Default constraint in SQL Server 2008?
My query is
alter table tbloffers
drop column checkin
I am getting below error
ALTER TABLE DROP COLUMN checkin failed because one or more objects access this column.
Can anyone correct my query to drop a column with constraint?
Best Answer
First you should drop the problematic
DEFAULT constraint
, after that you can drop the columnBut the error may appear from other reasons - for example the user defined function or view with
SCHEMABINDING
option set for them.UPD: Completely automated dropping of constraints script: