Wednesday, March 28, 2012

Remove default value from a table

Hi there.
I cannot figure this out, please help.
I have a table with an attribute with a default value. How do I erase this default value (with sql). I do not want to lose any data in my table.I didn't get that to work, it said I should use ALTER TABLE DROP CONSTRAINT. I have tried that before but without success.

But after a few minutes (almost an hour) I found a way to solve it:

ALTER TABLE voucher DROP CONSTRAINT DF__voucher__voucher__56D3D912;

The Constraint name I found by looking in the sysobjects table.

Thanks anyway!|||just do an alter table ... alter column ... and omit the default.

No comments:

Post a Comment