IF OBJECT_ID('CG_FND_VERBA_HIST') IS NULL
BEGIN
	CREATE TABLE [dbo].[CG_FND_VERBA_HIST](
		[CD_HIST] [int] NOT NULL,
		[CD_EMP] [int] NOT NULL,
		[CD_FND_VERBA] [int] NOT NULL,
		[TP_HIST] VARCHAR(200) NOT NULL,
		[DS_HIST] VARCHAR(200) NOT NULL,
		[CD_USU] [int] NOT NULL,
		[DT_HIST] [date] NOT NULL,
		[HR_HIST] [datetime] NOT NULL,
	 CONSTRAINT [PK_CG_FND_VERBA_HIST] PRIMARY KEY CLUSTERED 
	(
		[CD_HIST] 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]
END
GO

IF OBJECT_ID('FK_CG_FND_VERBA_HIST_CG_FND_VERBA') IS NULL
ALTER TABLE [dbo].[CG_FND_VERBA_HIST]  WITH CHECK ADD  CONSTRAINT [FK_CG_FND_VERBA_HIST_CG_FND_VERBA] FOREIGN KEY([CD_FND_VERBA], [CD_EMP])
REFERENCES [dbo].[CG_FND_VERBA] ([CD_FND_VERBA], [CD_EMP])
GO

ALTER TABLE [dbo].[CG_FND_VERBA_HIST] CHECK CONSTRAINT [FK_CG_FND_VERBA_HIST_CG_FND_VERBA]
GO

IF OBJECT_ID('FK_CG_FND_VERBA_HIST_GLB_USU') IS NULL
ALTER TABLE [dbo].[CG_FND_VERBA_HIST]  WITH CHECK ADD  CONSTRAINT [FK_CG_FND_VERBA_HIST_GLB_USU] FOREIGN KEY([CD_USU])
REFERENCES [dbo].[GLB_USU] ([CD_USU])
GO

ALTER TABLE [dbo].[CG_FND_VERBA_HIST] CHECK CONSTRAINT [FK_CG_FND_VERBA_HIST_GLB_USU]
GO
