
DROP PROCEDURE Copiar_IN_COMPETITIONPRICEDET_AlTemporalProc
GO
CREATE PROCEDURE Copiar_IN_COMPETITIONPRICEDET_AlTemporalProc
(	
	@SITEID		UD_IDSITE,
	@DATEPROCE	UD_FECHA,
	@COMPETITIONID	CHAR(2), 
	@CORRNBR	INT
)
AS
BEGIN
	BEGIN TRAN

	INSERT INTO TMP_IN_COMPETITIONPRICEDET(CORRNBR,SITEID,DATEPROCE,COMPETITIONID,INVTIDSKU,SLS_PRICE)
	SELECT @CORRNBR,SITEID,DATEPROCE,COMPETITIONID,INVTIDSKU,SLS_PRICE
	FROM IN_COMPETITIONPRICEDET 
	WHERE SITEID=@SITEID AND DATEPROCE=@DATEPROCE AND COMPETITIONID=@COMPETITIONID

	IF(@@ERROR!=0 OR @@ROWCOUNT=0)
	BEGIN
		ROLLBACK
		RAISERROR 20000 'Error Insertando en TMP_IN_COMPETITIONPRICEDET'
		RETURN(1)
	END

	COMMIT TRAN 
	RETURN(0)
END 


SELECT * FROM TMP_IN_COMPETITIONPRICEDET