I'm creating two foreign key references pointing to two different tables, but I'm getting an error creating one.
There are no primary or candidate keys in the referenced table 'dbo.TB_PODERES' that match the referencing column list in the foreign key 'FK_TB_GRUPOS_PODERES_PODERES_TB_PODERES'.
The reference table is as follows
CREATE TABLE [dbo].[TB_PODERES](
[ID_PDR] [int] IDENTITY(1,1) NOT NULL,
[CD_PODER] [char](10) NOT NULL,
[NM_PODER] [varchar](100) NOT NULL,
[IC_ATIVO] [bit] NOT NULL,
[DT_ULT_ATUALIZACAO] [datetime] NOT NULL,
CONSTRAINT [PK_TB_PODERES_PODER] PRIMARY KEY NONCLUSTERED
(
[ID_PDR] ASC,
[CD_PODER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
and the table I'm creating is FK.
CREATE TABLE [dbo].[TB_GRUPOS_PODERES_PODERES](
[ID_GPP] BIGINT IDENTITY(1,1) NOT NULL,
[ID_GRP_PDR] [bigint] NOT NULL,
[CD_PODER] [char](10) NOT NULL,
[IC_ATIVO] [bit] NOT NULL,
[DT_ULT_ATUALIZACAO] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED
(
[ID_GPP],[ID_GRP_PDR],[CD_PODER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].TB_GRUPOS_PODERES_PODERES WITH CHECK ADD CONSTRAINT FK_TB_GRUPOS_PODERES_PODERES_TB_PODERES FOREIGN KEY([CD_PODER])
REFERENCES [dbo].TB_PODERES ([CD_PODER])
GO
ALTER TABLE [dbo].TB_GRUPOS_PODERES_PODERES CHECK CONSTRAINT FK_TB_GRUPOS_PODERES_PODERES_TB_PODERES
GO