SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Data Corruption Issues
 Error mssg 1776
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CN29
Starting Member

USA
1 Posts

Posted - 11/20/2010 :  20:02:59  Show Profile  Reply with Quote
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
3367 Posts

Posted - 11/20/2010 :  20:10:29  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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

USA
5071 Posts

Posted - 11/20/2010 :  22:56:34  Show Profile  Visit russell's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000