/****** Object:  Trigger [TRG_EST_NF_ENT_ESTORNO] Script Date: 01/14/2014 17:29:43 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRG_EST_NF_ENT_ESTORNO]'))
DROP TRIGGER [dbo].[TRG_EST_NF_ENT_ESTORNO]
GO 
 /* 
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [DBO].[TRG_EST_NF_ENT_ESTORNO] ON [DBO].[EST_NF_ENT] 
FOR DELETE
AS 
	DECLARE @CD_EMP INT,
		@CD_FILIAL INT,
		@CD_NF	INT; 
	
	SELECT TOP 1
		@CD_EMP = CD_EMP,
		@CD_FILIAL = CD_FILIAL,
		@CD_NF	=CD_NF
	FROM DELETED ;

	EXEC P_EST_NF_ENT_IT_ESTORNO_DELETE @CD_EMP, @CD_FILIAL, @CD_NF ,0 ; 

	DELETE FROM E
	FROM
		EST_NF_ENT E  
		INNER JOIN DELETED D ON 
		E.CD_EMP	= D.CD_EMP AND
		E.CD_NF		= D.CD_NF AND
		E.CD_FILIAL = D.CD_FILIAL;
*/
GO


