IF NOT EXISTS (
    SELECT 1 
    FROM sys.objects 
    WHERE object_id = OBJECT_ID('dbo.EST_PROD_EST_SNGPC_CPL') 
      AND type = 'U'
)
BEGIN

	CREATE TABLE EST_PROD_EST_SNGPC_CPL (CD_EMP INT,
											CD_FILIAL INT,
											CD_PROD INT,
											PROD_INCONSISTENTE_ANVISA INT,
											CD_USU INT,
											DT_ULT_ALT DATETIME,

											CONSTRAINT PK_EST_PROD_EST_SNGPC_CPL
											PRIMARY KEY (CD_EMP, CD_FILIAL, CD_PROD),

											CONSTRAINT FK_EST_PROD_EST_PROD_EST_SNGPC_CPL
											FOREIGN KEY (CD_EMP, CD_PROD)
											REFERENCES EST_PROD (CD_EMP, CD_PROD),

											CONSTRAINT FK_GLB_USU_EST_PROD_EST_SNGPC_CPL
											FOREIGN KEY (CD_USU)
											REFERENCES GLB_USU (CD_USU)
											)
   
END
GO
