IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP]')) 
	BEGIN 
		RETURN;
	END
ELSE
	BEGIN
		CREATE TABLE [dbo].[EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP](
			CD_EMP INT NOT NULL,
			CD_PROD INT NOT NULL,
			CD_REGIAO_FISCAL INT NOT NULL,
			CD_CTR INT NOT NULL,
		 CONSTRAINT [PK_EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP] PRIMARY KEY CLUSTERED 
		(
			CD_EMP ASC,
			CD_PROD ASC,
			CD_REGIAO_FISCAL ASC,
			CD_CTR ASC  
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
		) ON [PRIMARY]

		

		ALTER TABLE [dbo].[EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP]  WITH NOCHECK ADD  CONSTRAINT [FK_EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP_EST_PROD] FOREIGN KEY([CD_EMP],[CD_PROD])
		REFERENCES [dbo].[EST_PROD] ([CD_EMP],[CD_PROD])
		ON DELETE CASCADE
		ON UPDATE CASCADE
		


		ALTER TABLE [dbo].[EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP]  WITH NOCHECK ADD  CONSTRAINT [FK_EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP_PRC_REGIAO_FISCAL] FOREIGN KEY([CD_REGIAO_FISCAL])
		REFERENCES [dbo].[PRC_REGIAO_FISCAL] ([CD_REGIAO_FISCAL])
		 


		ALTER TABLE [dbo].[EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP]  WITH NOCHECK ADD  CONSTRAINT [FK_EST_PROD_PRC_REGIAO_FISCAL_EST_TRIB_CONF_GRP_EST_TRIB_CONF_GRP] FOREIGN KEY([CD_EMP],[CD_CTR])
		REFERENCES [dbo].[EST_TRIB_CONF_GRP] ([CD_EMP],[CD_CTR])
		ON DELETE CASCADE
		ON UPDATE CASCADE
		 
	END
	