DROP PROCEDURE GrabarDetFaltaSobraProc
GO
CREATE PROCEDURE GrabarDetFaltaSobraProc
(	@CORRNBR int

)
AS
BEGIN    

	DECLARE   @ERROR	integer


       INSERT 	INTO 	OP_CCSALESPERSONDET(SITEID,DATEPROCE,SALESPERID,CCSALESPERSONTYPEID,TOTALPEN,TOTALUSD,OBS)
		SELECT 	SITEID,DATEPROCE,SALESPERID,CCSALESPERSONTYPEID,TOTALPEN,TOTALUSD,OBS
		FROM	TMP_OP_CCSALESPERSONDET
		WHERE	CORRNBR=@CORRNBR

	IF (@@error!=0 OR @@ROWCOUNT=0 )
    	BEGIN
        	RETURN(1)
    	END

  RETURN (0)

END

SELECT * FROM OP_CCSALESPERSONDET