IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_EXCLUI_PENDENCIA]'))
DROP TRIGGER [dbo].[TRG_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_EXCLUI_PENDENCIA]
GO
/****** Object:  Trigger [TRG_EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT_EXCLUI_PENDENCIA]  ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT_EXCLUI_PENDENCIA]'))
DROP TRIGGER [dbo].[TRG_EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT_EXCLUI_PENDENCIA]
GO
GO
CREATE TRIGGER [dbo].[TRG_EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT_EXCLUI_PENDENCIA] ON [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT] FOR INSERT AS
DELETE FROM p FROM EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE p WHERE EXISTS
    (SELECT * FROM INSERTED WHERE CD_CTR=p.CD_CTR)

GO

ALTER TABLE [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT] ENABLE TRIGGER [TRG_EST_NF_SAI_LOTE_ENVIO_WMS_EST_WMS_ENT_EXCLUI_PENDENCIA]
