IF OBJECT_ID('GLB_EMAIL_ENV_FP_FUNC') IS NULL
	BEGIN 
		CREATE TABLE [dbo].[GLB_EMAIL_ENV_FP_FUNC](
			[CD_CTR] [int] NOT NULL,
			[CD_EMP] [int] NOT NULL,
			[CD_FUN] [int] NOT NULL,
			[TP_DEST] [int] NOT NULL,	
		 CONSTRAINT [PK_GLB_EMAIL_ENV_FP_FUNC] PRIMARY KEY CLUSTERED 
		(
			[CD_CTR] ASC,
			[CD_EMP] ASC,
			[CD_FUN] 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].[GLB_EMAIL_ENV_FP_FUNC]  WITH CHECK ADD  CONSTRAINT [FK_GLB_EMAIL_ENV_FP_FUNC_FP_FUNC] FOREIGN KEY([CD_EMP], [CD_FUN])
		REFERENCES [dbo].[FP_FUNC] ([CD_EMP], [CD_FUN])
		ON UPDATE CASCADE
		 

		ALTER TABLE [dbo].[GLB_EMAIL_ENV_FP_FUNC] CHECK CONSTRAINT [FK_GLB_EMAIL_ENV_FP_FUNC_FP_FUNC]
		 

		ALTER TABLE [dbo].[GLB_EMAIL_ENV_FP_FUNC]  WITH CHECK ADD  CONSTRAINT [FK_GLB_EMAIL_ENV_FP_FUNC_GLB_EMAIL_ENV] FOREIGN KEY([CD_CTR])
		REFERENCES [dbo].[GLB_EMAIL_ENV] ([CD_CTR])
		ON UPDATE CASCADE
		 

		ALTER TABLE [dbo].[GLB_EMAIL_ENV_FP_FUNC] CHECK CONSTRAINT [FK_GLB_EMAIL_ENV_FP_FUNC_GLB_EMAIL_ENV]
		 

		ALTER TABLE [dbo].[GLB_EMAIL_ENV_FP_FUNC] ADD  CONSTRAINT [DF_GLB_EMAIL_ENV_FP_FUNC_TP_DEST]  DEFAULT ((0)) FOR [TP_DEST]
		 
	END