Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Column Error 1

Status
Not open for further replies.

jmcg

Technical User
Joined
Jun 30, 2000
Messages
223
Location
GB
I am trying to drop a column in my SQL Server 2005 database and getting an error.
The code I am running is:
Code:
ALTER TABLE Targets DROP COLUMN Connections
and I am getting the error:
Code:
The object 'DF___Targets_Conne___25A75D29' is dependant on column 'Connections'
Any suggestions to what may be the problem?
 
You have set default value for this column and SQL Server generate a strange name for the constraint :-).
You should drop this constraint before you drop the column.

Code:
ALTER TABLE Targets 
       DROP CONSTRAINT DF___Targets_Conne___25A75D29
GO
ALTER TABLE Targets DROP COLUMN Connections

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Borislav
Thanks this works.

Does this means that if I remove the default values for the field then I will not need the DROP CONSTRAINT element?
 
Sure,
SQL Serer will remove that constraints for you when you press save button.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Excellent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top