dbo.Pasa_Empleados_Temp

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

/*

EXEC Pasa_Empleados_Temp


select count(id_empleado) from empleados_temp where procesado is null or procesado = 0


*/



CREATE OR ALTER PROCEDURE  dbo.Pasa_Empleados_Temp
AS

BEGIN
 SET NOCOUNT ON;

DECLARE @ERRORNUMBER int

DECLARE @IDEmp INT

 begin
   
 DECLARE EmpleadosTempPendientes Cursor
  FOR
  select top 1000 id_empleado from empleados_temp
  /*
    where (procesado is null or procesado = 0) 
    */

  /*
   and cuit = '30504163543'
   */

  Open EmpleadosTempPendientes

  Fetch NEXT FROM EmpleadosTempPendientes INTO @IDEmp

  While (@@FETCH_STATUS = 0)
  BEGIN

  
  BEGIN TRY


   insert into empleados (cuit,cuil,codrect,fechapres,periodo,remimp,remtot,visible)
   select cuit,cuil,codrect,fechapres,periodo,remimp,remtot,visible
   from empleados_temp where id_empleado  = @IDEmp

   delete empleados_temp where id_empleado =@IDEmp


  END TRY

  BEGIN CATCH

  SET @ERRORNUMBER = 1

  END CATCH

  Fetch NEXT FROM EmpleadosTempPendientes INTO @IDEmp

  END

  CLOSE EmpleadosTempPendientes
  DEALLOCATE EmpleadosTempPendientes
end
END

GO

Depends On

No items found

Used By

No items found