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 |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2008-05-07 : 11:28:27
|
| Hello,I am trying to create a table to implement the adjacency model so I can have categories and subcategories in a single table.When I try to create the table I get the following error:"Foreign key 'FK_Parent' references invalid column 'ParentID' in referencing table 'Categories'. Could not create constraint."create table dbo.Categories( CategoryID uniqueidentifier not null constraint PK_Category primary key clustered, [Name] nvarchar(200) not null, ParentiID uniqueidentifier null, constraint FK_Parent foreign key(ParentID) references dbo.Categories(CategoryID))What am I doing wrong?Thanks,Miguel |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-05-07 : 11:30:32
|
| you put ParentiID. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-07 : 11:38:50
|
quote: Originally posted by shapper Hello,I am trying to create a table to implement the adjacency model so I can have categories and subcategories in a single table.When I try to create the table I get the following error:"Foreign key 'FK_Parent' references invalid column 'ParentID' in referencing table 'Categories'. Could not create constraint."create table dbo.Categories( CategoryID uniqueidentifier not null constraint PK_Category primary key clustered, [Name] nvarchar(200) not null, ParentiID uniqueidentifier null, constraint FK_Parent foreign key(ParentID) references dbo.Categories(CategoryID))What am I doing wrong?Thanks,Miguel
There is a typo. its ParentID not ParentiID |
 |
|
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2008-05-07 : 12:47:20
|
| Hi,Thanks. Sorry ... I was trying for 5 minutes and didn't notice the error ... I though it was my code.Thanks,Miguel |
 |
|
|
|
|
|
|
|