| Author |
Topic  |
|
|
CN29
Starting Member
USA
1 Posts |
Posted - 11/20/2010 : 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
Flowing Fount of Yak Knowledge
United Kingdom
3328 Posts |
Posted - 11/20/2010 : 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. |
 |
|
|
russell
Pyro-ma-ni-yak
USA
4984 Posts |
Posted - 11/20/2010 : 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) );
|
 |
|
| |
Topic  |
|
|
|