DROP PROCEDURE IN_COMPETITIONPRICEDETInsProc
GO
CREATE PROCEDURE IN_COMPETITIONPRICEDETInsProc
(	@CORRNBR	INT

)
AS
BEGIN
	BEGIN TRAN


	INSERT 	INTO IN_COMPETITIONPRICEDET(SITEID,DATEPROCE,COMPETITIONID,INVTIDSKU,SLS_PRICE)
	SELECT  SITEID,DATEPROCE,COMPETITIONID,INVTIDSKU,SLS_PRICE FROM TMP_IN_COMPETITIONPRICEDET
	WHERE 	CORRNBR=@CORRNBR
	
	IF(@@ERROR!=0 OR @@ROWCOUNT=0)
	BEGIN
		ROLLBACK
		RAISERROR 20000 'Error Insentando Registros'
		RETURN(1)
	END 

	COMMIT TRAN
	RETURN(0)
END 



SELECT SITEID AS Almacen,DATEPROCE as Fech_Proc,COMPETITIONID as cod,INVTIDSKU,SLS_PRICE
FROM IN_COMPETITIONPRICEDET