IF OBJECT_ID('CG_FND_VERBA_PRC_FILIAL') IS NOT NULL 
BEGIN
	GOTO FINAL
END

CREATE TABLE [dbo].[CG_FND_VERBA_PRC_FILIAL](
	[CD_EMP] [int] NOT NULL,
	[CD_FND_VERBA] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
 CONSTRAINT [PK_CG_FND_VERBA_PRC_FILIAL] PRIMARY KEY CLUSTERED 
(
	[CD_FND_VERBA] ASC,
	[CD_FILIAL] ASC,
	[CD_EMP] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]


FINAL:
GO


IF OBJECT_ID('FK_CG_FND_VERBA_PRC_FILIAL_CG_FND_VERBA') IS NOT NULL 
BEGIN
	GOTO FINAL
END

ALTER TABLE [dbo].[CG_FND_VERBA_PRC_FILIAL]  WITH CHECK ADD  CONSTRAINT [FK_CG_FND_VERBA_PRC_FILIAL_CG_FND_VERBA] FOREIGN KEY([CD_FND_VERBA], [CD_EMP])
REFERENCES [dbo].[CG_FND_VERBA] ([CD_FND_VERBA], [CD_EMP])

ALTER TABLE [dbo].[CG_FND_VERBA_PRC_FILIAL] CHECK CONSTRAINT [FK_CG_FND_VERBA_PRC_FILIAL_CG_FND_VERBA]

FINAL:
GO

IF OBJECT_ID('FK_CG_FND_VERBA_PRC_FILIAL_PRC_FILIAL') IS NOT NULL 
BEGIN
	GOTO FINAL
END

ALTER TABLE [dbo].[CG_FND_VERBA_PRC_FILIAL]  WITH CHECK ADD  CONSTRAINT [FK_CG_FND_VERBA_PRC_FILIAL_PRC_FILIAL] FOREIGN KEY([CD_EMP], [CD_FILIAL])
REFERENCES [dbo].[PRC_FILIAL] ([CD_EMP], [CD_FILIAL])

ALTER TABLE [dbo].[CG_FND_VERBA_PRC_FILIAL] CHECK CONSTRAINT [FK_CG_FND_VERBA_PRC_FILIAL_PRC_FILIAL]
FINAL:
GO