View Single Post
  #1 (permalink)  
Old May 13th, 2013, 02:15 PM
DJRomano DJRomano is offline
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question ALTER TABLE ADD CONSTRAINT

Chapter 6: Constraints
Page 152

Entered the following code from the book:

USE Accounting

ALTER TABLE dbo.Employees
ADD CONSTRAINT FK_EmployeeHasManager
FOREIGN KEY (ManagerEmplID)
REFERENCES dbo.Employees(EmployeeID)

I receive the following msg:

Msg 547, Level 16, State 0, Line 3
The ALTER TABLE statement conflicted with the FOREIGN KEY SAME TABLE constraint "FK_EmployeeHasManager". The conflict occurred in database "Accounting", table "dbo.Employees", column 'EmployeeID'.

When I execute EXEC sp_helpconstraint Employees, the only constraint that appears is the PRIMARY KEY. I can't identify anything in sp_helpdb that would prevent me from doing this.

Can somebody help me?
Reply With Quote