I have the following .sql script creating 2 tables but I'm getting an error stating:
"There are no primary or candidate keys in the referenced table 'dbo.FilingMethodProfilesRules' that match the referencing column list in the foreign key 'FK__FilingMet__RuleI__2106348D'."
I have the primary key set in the referenced table which is also created in this same statement. My script is as follows:
I'm not sure why I'm getting this error.
"There are no primary or candidate keys in the referenced table 'dbo.FilingMethodProfilesRules' that match the referencing column list in the foreign key 'FK__FilingMet__RuleI__2106348D'."
I have the primary key set in the referenced table which is also created in this same statement. My script is as follows:
Code:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FilingMethodProfilesRules]') and OBJECTPROPERTY(id, N'IsTable') = 1)
drop TABLE [dbo].[FilingMethodProfilesRules]
GO
Create Table dbo.FilingMethodProfilesRules
(
RuleID int NOT NULL IDENTITY(1,1),
RuleDesc varchar(30)
)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FilingMethodProfiles]') and OBJECTPROPERTY(id, N'IsTable') = 1)
drop TABLE [dbo].[FilingMethodProfiles]
GO
Create Table dbo.FilingMethodProfiles
(
ProfileID int NOT NULL IDENTITY(1,1),
CatalogID int NOT NULL FOREIGN KEY (CatalogID) REFERENCES dbo.Catalog(CatalogID),
[Description] varchar(10),
RuleID int NOT NULL FOREIGN KEY (RuleID) REFERENCES dbo.FilingMethodProfilesRules(RuleID)
)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
I'm not sure why I'm getting this error.