
/****** Object:  Trigger [TRG_RC_CONC_PDV_VD_TEF_CONCILIADO_EXCLUI_PENDENCIA]    Script Date: 08/08/2012 10:00:52 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_RC_CONC_PDV_VD_TEF_CONCILIADO_EXCLUI_PENDENCIA]'))
DROP TRIGGER [dbo].[TRG_RC_CONC_PDV_VD_TEF_CONCILIADO_EXCLUI_PENDENCIA]
GO
GO
------------------------------INSERÇÃO EM RC_CONC_PDV_VD_TEF_CONCILIADO-----------------------------------
CREATE TRIGGER [dbo].[TRG_RC_CONC_PDV_VD_TEF_CONCILIADO_EXCLUI_PENDENCIA] ON [dbo].[RC_CONC_PDV_VD_TEF_CONCILIADO] FOR INSERT AS
DELETE FROM p FROM RC_CONC_PDV_VD_TEF_ENVIO_PENDENCIA p WHERE EXISTS
    (SELECT 
		* 
	FROM 
		INSERTED I
	WHERE 
		I.CD_EMP=p.CD_EMP AND 
		I.CD_FILIAL=p.CD_FILIAL AND 
		I.CD_CTR_LOTE=p.CD_CTR_LOTE AND
		I.CD_VD=p.CD_VD AND
		I.CD_CTR=p.CD_CTR)
GO

ALTER TABLE [dbo].[RC_CONC_PDV_VD_TEF_CONCILIADO] ENABLE TRIGGER [TRG_RC_CONC_PDV_VD_TEF_CONCILIADO_EXCLUI_PENDENCIA]
GO


