if not exists (SELECT 
    OBJECT_NAME(OBJECT_ID) AS NameofConstraint
        ,SCHEMA_NAME(schema_id) AS SchemaName
        ,OBJECT_NAME(parent_object_id) AS TableName
        ,type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT'
        AND OBJECT_NAME(OBJECT_ID)='FK_EST_PROD_PRC_BANDEIRA_PRC_BANDEIRA_CD_BANDEIRA')
BEGIN
	ALTER TABLE EST_PROD_PRC_BANDEIRA ADD CONSTRAINT FK_EST_PROD_PRC_BANDEIRA_PRC_BANDEIRA_CD_BANDEIRA FOREIGN KEY (CD_BANDEIRA) REFERENCES PRC_BANDEIRA (CD_BANDEIRA)
END

if not exists (SELECT 
    OBJECT_NAME(OBJECT_ID) AS NameofConstraint
        ,SCHEMA_NAME(schema_id) AS SchemaName
        ,OBJECT_NAME(parent_object_id) AS TableName
        ,type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT'
        AND OBJECT_NAME(OBJECT_ID)='FK_EST_PROD_PRC_BANDEIRA_EST_PROD_CD_PROD')
BEGIN
ALTER TABLE EST_PROD_PRC_BANDEIRA ADD CONSTRAINT FK_EST_PROD_PRC_BANDEIRA_EST_PROD_CD_PROD FOREIGN KEY (CD_EMP, CD_PROD) REFERENCES EST_PROD (CD_EMP, CD_PROD)
END