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.

 All Forums
 General SQL Server Forums
 Data Corruption Issues
 Error mssg 1776

Author  Topic 

CN29
Starting Member

1 Post

Posted - 2010-11-20 : 20:02:59
I'm receiving MSG 1776-There are no primary or candidate keys in the referenced table 'Movie' that match the referencing column list in the foreign key 'fk_show_movie'

when I enter the following code, but MovieID does exists in the table Movie

create table Movie (
MovieID char(5) not null
,StarActorName varchar (25) not null
,MovieTitle varchar (25) not null
,Genre varchar (15) not null
,Director varchar (25) not null
,ReleaseDate Date not null
,constraint pk_Movie primary key (MovieID)
,constraint fk_movie_StarActor foreign key (StarActorName) Added
references StarActor (StarActorName)
);


create table Show(
ShowID char(5) not null
,MovieID char (5) not null
,Duration Time(0) not null
,constraint pk_show primary key (ShowID)
,constraint fk_show_movie foreign key (MovieID) references
Movie (MovieID)
);


Can someone help me??

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-20 : 20:10:29
It's saying that MovieID doesn't have a unique index on it. Not true from your statements here as it is a PK so I suspect the table doesn't match this definition.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-20 : 22:56:34
create table Movie (
MovieID char(5) not null
,StarActorName varchar (25) not null
,MovieTitle varchar (25) not null
,Genre varchar (15) not null
,Director varchar (25) not null
,ReleaseDate Date not null
,constraint pk_Movie primary key (MovieID)
,constraint fk_movie_StarActor foreign key (StarActorName) Added
references StarActor (StarActorName)
);

GO
create table Show(
ShowID char(5) not null
,MovieID char (5) not null
,Duration Time(0) not null
,constraint pk_show primary key (ShowID)
,constraint fk_show_movie foreign key (MovieID) references
Movie (MovieID)
);

Go to Top of Page
   

- Advertisement -