Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I drop a column with a default?
Message
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Database management
Title:
How do I drop a column with a default?
Miscellaneous
Thread ID:
00570572
Message ID:
00570572
Views:
53
alter table TBL add TBLJUNK3 char(20) not null default ''

That works fine. Now I want to remove it. I try:
  alter table TBL drop column TBLJUNK3
and it tells me
  The object 'DF__TBL__TBLJUNK3__084B3915' is dependent on column 'TBLJUNK3'.

I'm assuming that this funny thing is the default it created for this column for me. So I figure I should first try to clear the default before I drop the column, but I can't seem to drop or clear the default.

I tried:
  EXEC sp_unbindefault 'tbl.tbljunk3'
and it tells me to use ALTER TABLE DROP CONSTRAINT. But I can't get that to work.

I also tried
  alter table TBL alter column TBLJUNK3 drop default
and of course
  alter table TBL alter column TBLJUNK3 drop constraint
but all come back with syntax errors.

All I want to do is to delete a stupid column! What is the secret, and how come it's so hard? (Don't feel obliged to answer the last part of that.)

Thanks for your help. Tom
Tom Green in Montreal
Next
Reply
Map
View

Click here to load this message in the networking platform