IF not EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EST_PROD_TRANSF_MINUTA_ENTREGA_CPL_EST_NF_SAI_EST_NF_SAI]') AND parent_object_id = OBJECT_ID(N'[dbo].[EST_PROD_TRANSF_MINUTA_ENTREGA_CPL_EST_NF_SAI]'))
begin
ALTER TABLE dbo.EST_PROD_TRANSF_MINUTA_ENTREGA_CPL_EST_NF_SAI ADD CONSTRAINT
	FK_EST_PROD_TRANSF_MINUTA_ENTREGA_CPL_EST_NF_SAI_EST_NF_SAI FOREIGN KEY
	(
	CD_EMP,
	CD_FILIAL,
	CD_NF
	) REFERENCES dbo.EST_NF_SAI
	(
	CD_EMP,
	CD_FILIAL,
	CD_NF
	) ON UPDATE  NO ACTION 
	 ON DELETE  NO ACTION 
end	
