-1

I try to drop all the foreign and primary keys for an assignment, but so far I get the following error:

Msg 3728, Level 16, State 1, Line 3
'fk_DEPENDENT_ESSN' is not a constraint.

Msg 3727, Level 16, State 0, Line 3
Could not drop constraint. See previous errors.

Here are my commands:

Use Company;
Go

--Dropping FKs from Dependent Table
ALTER TABLE Dependent
DROP fk_DEPENDENT_ESSN

--Dropping FKs from Dept_Locations Table
ALTER TABLE Dept_Locations
DROP fk__DEPT_LOCATIONS__Dnumber

--Dropping FKs from Employee Table
ALTER TABLE Employee
DROP FK__Employee__Dno

ALTER TABLE Employee
DROP FK__Employee__Super___ssn

--Dropping FKs from Project Table
ALTER TABLE Project
DROP FK__Project

--Dropping FKs from WORKS_ON Table
ALTER TABLE WORKS_ON
DROP FK__WORKS_ON__Essn

ALTER TABLE WORKS_ON
DROP FK__WORKS_ON__PNO

How should I fix this, sorry I can't post my database on here. if you have any questions, feel free to comment or we can email.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lin Wei
  • 87
  • 1
  • 5

1 Answers1

0

The error is because fk_DEPENDENT_ESSN does not exist. Are you missing and underscore? Should be fk__DEPENDENT_ESSN?

You can check what the names of the FK are using the sysobjects table.

SELECT * FROM sysobjects WHERE name LIKE '%DEPENDENT_ESSN'

See SQL Server 2008 cannot drop constraint

Community
  • 1
  • 1
Dave Anderson
  • 11,836
  • 3
  • 58
  • 79