Hi,
I am using SQL Server 7.0
TABLE1
======
Fld1
Fld2
Fld3
Fld4
Fld5
Fld6
Primary Key = Fld1 + Fld2 + Fld3
TABLE2
======
Fld1
Fld2
Fld3
Fld4
Fld5
Foriegn Key = Fld5 (Referencing TABLE1.Fld3) The datatypes are
matching in both tables.
I am trying to create the foreign key by giving the following command:
ALTER TABLE TABLE2 ADD
CONSTRAINT [FK_TABLE2_TABLE 1] FOREIGN KEY
(
[Fld5]
) REFERENCES TABLE1 (
[Fld3]
)
GO
This is giving the following error:
There are no primary or candidate keys in the referenced table
'TABLE1' that match the referencing column list in the foreign key
'FK_TABLE2_TABL E1'.
Any help?
Regards,
Kamlesh
I am using SQL Server 7.0
TABLE1
======
Fld1
Fld2
Fld3
Fld4
Fld5
Fld6
Primary Key = Fld1 + Fld2 + Fld3
TABLE2
======
Fld1
Fld2
Fld3
Fld4
Fld5
Foriegn Key = Fld5 (Referencing TABLE1.Fld3) The datatypes are
matching in both tables.
I am trying to create the foreign key by giving the following command:
ALTER TABLE TABLE2 ADD
CONSTRAINT [FK_TABLE2_TABLE 1] FOREIGN KEY
(
[Fld5]
) REFERENCES TABLE1 (
[Fld3]
)
GO
This is giving the following error:
There are no primary or candidate keys in the referenced table
'TABLE1' that match the referencing column list in the foreign key
'FK_TABLE2_TABL E1'.
Any help?
Regards,
Kamlesh
Comment