Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ghostfly
Starting Member
6 Posts |
Posted - 2011-02-12 : 20:50:52
|
Trying to make a foreign key and I keep getting errorsMsg 1769, Level 16, State 1, Line 6Foreign key 'DepartID' references invalid column 'DepartID' in referencing table 'EmployeesF'.Msg 1750, Level 16, State 0, Line 6Could not create constraint. See previous errors.Alter Table EmployeesFAdd foreign Key (DepartmentID) references Departments(DepartmentID) my tablesCreate Table Departments(DepartmentID int Not Null,DepartmentName varchar(255),LocationID int,Primary Key(DepartmentID),Foreign Key(LocationID) references Locations(LocationID))Create Table EmployeesF(EmployeeID int Not Null,FirstName varchar(255),LastName varchar(255),EMail varchar(255),Salary int,PhoneNumber varchar(15),HireDate date,Primary Key(EmployeeID),Foreign Key(ManagerID) references Employees(EmployeeID))CREATE TABLE Locations(LocationID int NOT NULL,PostalCode int ,City varchar(255),StateProvince varchar(255),Country varchar(255),PRIMARY KEY (LocationID),) |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-12 : 22:21:57
|
DepartmentID should be a column in table EmployeesF KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
ghostfly
Starting Member
6 Posts |
Posted - 2011-02-13 : 08:40:56
|
| TYMV you helped me greatly |
 |
|
|
|
|
|
|
|