Sunday, February 26, 2012

Find and drop a constraint before dropping the column

Hi all.
I want to check and find the name of the constraint and drop it before I
drop the column. Or, just drop the column without the errormessage that
there are depending objects. Any ideas?
Now I have to drop the column, look at the errormessage, copy/paste into a
drop constraint and then drop the column again.
Thanx all.
ALTER TABLE Tablename
DROP CONSTRAINT DF__Tablename__ColumnName__21D6CC45
GO
ALTER TABLE Tablename
DROP COLUMN ColumnName
goYou can use sp_help and sp_helpconstraint.
can view PK, FK,ID,CHECK etc.
"Geir Holme"?? ??? ??:

> Hi all.
> I want to check and find the name of the constraint and drop it before I
> drop the column. Or, just drop the column without the errormessage that
> there are depending objects. Any ideas?
> Now I have to drop the column, look at the errormessage, copy/paste into a
> drop constraint and then drop the column again.
> Thanx all.
>
> ALTER TABLE Tablename
> DROP CONSTRAINT DF__Tablename__ColumnName__21D6CC45
> GO
> ALTER TABLE Tablename
> DROP COLUMN ColumnName
> go
>
>

No comments:

Post a Comment