Reputation: 2720
I have altered a table "luAffinity" by adding an additional column "AOTProcessRealTime" to it. I have added a default constraint to the column "AOTProcessRealTime". Below is the query that I have fired:
ALTER TABLE luAffinity ADD AOTProcessRealTime BIT NOT NULL CONSTRAINT DF_luAffinity_ProcessRealTime DEFAULT 0
Now I wanted to delete the column AOTProcessRealTime. For this, I have to delete the default constraint first. So I wrote the following query to delete the constraint:
ALTER TABLE luAffinity
DROP CONSTRAINT DF_luAffinity_ProcessRealTime
On running the above query, I am gettin an error:
DF_luAffinity_ProcessRealTime is not a constraint. Could not drop constraint.
However, the constraint has been successfully created but I am not able to delete it. I just wanted to delete the column AOTProcessRealTime. But I am not able to delete it. Am I doing something wrong? Any help will be appreciated
Upvotes: 0
Views: 1111
Reputation: 40359
For SQL Server, your syntax should work. Perhaps there is a subtle typo in the name of the constraint? Use
SELECT *
from sys.default_constraints
where parent_object_id = object_id('luAffinity')
to check how it is currently set.
Upvotes: 2