-----------------------------------DELEÇÃO EM EST_PROD_REQ_TRANSF_LIB_ITENS_ENT_EST_PROD_IMP-----------------------------------  
ALTER TRIGGER [dbo].[TRG_EST_PROD_REQ_TRANSF_LIB_ITENS_ENT_EST_PROD_IMP_INCLUI_PENDENCIA] ON [dbo].[EST_PROD_REQ_TRANSF_LIB_ITENS_ENT_EST_PROD_IMP] FOR DELETE AS  
--Pendência de entrada pré-faturas transferências (SEPARADO NO ESTOQUE)  
INSERT INTO EST_PROD_REQ_TRANSF_LIB_PENDENTE (  
  CD_EMP,   
  CD_FILIAL,   
  CD_REQ,   
  CD_FILIAL_DEST)  
 SELECT   
  DISTINCT p.CD_EMP,   
  p.CD_FILIAL,   
  p.CD_REQ,   
  p.CD_FILIAL_DEST  
    FROM    
  DELETED d INNER JOIN EST_PROD_REQ_TRANSF_LIB p ON   
  p.CD_EMP=d.CD_EMP AND   
  p.CD_FILIAL_DEST=d.CD_FILIAL_ORIG AND   
  p.CD_REQ=d.CD_REQ
  where not exists (select 1 from EST_PROD_REQ_TRANSF_LIB_PENDENTE pend
					where pend.CD_EMP  = p.CD_EMP and pend.CD_FILIAL = p.CD_FILIAL 
					and p.CD_REQ = pend.CD_REQ and p.CD_FILIAL_DEST = pend.CD_FILIAL_DEST )
