IF NOT OBJECT_ID('TRG_PDV_VD_FECHA_MOV_TES_PDV_CONSLD_VD_REPROCESSAR') IS NULL
	BEGIN 
		DROP TRIGGER TRG_PDV_VD_FECHA_MOV_TES_PDV_CONSLD_VD_REPROCESSAR 
	END 
GO
CREATE TRIGGER [dbo].[TRG_PDV_VD_FECHA_MOV_TES_PDV_CONSLD_VD_REPROCESSAR] ON [dbo].[PDV_VD_FECHA_MOV_TES] FOR  INSERT,UPDATE AS
BEGIN
	DELETE 
		c
	FROM 
		PDV_CONSLD_VD_MOVIMENTO_REPROCESSAR c INNER JOIN INSERTED i ON
		c.CD_EMP = i.CD_EMP AND
		c.CD_FILIAL = i.CD_FILIAL AND
		c.DT_MOV = i.DT_MOV

		INSERT INTO PDV_CONSLD_VD_MOVIMENTO_REPROCESSAR
		SELECT
			distinct
			i.CD_EMP,
			i.CD_FILIAL,
			i.DT_MOV,
			'BLOQUEIO DE CAIXA',
			GETDATE()
		FROM
			INSERTED i 
		END


