
DROP PROCEDURE Copiar_IN_COMPETITIONPRICE_AlTemporalProc
GO
CREATE PROCEDURE Copiar_IN_COMPETITIONPRICE_AlTemporalProc
(	
	@SITEID		UD_IDSITE,
	@DATEPROCE	UD_FECHA, 
	@CORRNBR	INT
)
AS
BEGIN
	BEGIN TRAN

	INSERT INTO TMP_IN_COMPETITIONPRICE(CORRNBR,SITEID,DATEPROCE,INVTIDSKU,PRICESUGGESTED,PRICECURRENT,PRICEPREVIOUS)
	SELECT @CORRNBR,SITEID,DATEPROCE,INVTIDSKU,PRICESUGGESTED,PRICECURRENT,PRICEPREVIOUS
	FROM IN_COMPETITIONPRICE 
	WHERE SITEID=@SITEID AND DATEPROCE=@DATEPROCE

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

	COMMIT TRAN 
	RETURN(0)
END 


SELECT * FROM TMP_IN_COMPETITIONPRICE