dbo.Imperium_sync_tipo_contratista

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
CREATE OR ALTER PROCEDURE dbo.Imperium_sync_tipo_contratista 

AS
BEGIN
    SET NOCOUNT ON;
 declare @C int
 declare @TC int
 declare @CM int
 declare @IDM int
 declare @TCM int

 DECLARE C_Sync CURSOR FOR

  select led_contratistas.contratista as C,led_contratistas.tipo_contratista as TC,led_contratista_multi.contratista as CM,led_contratista_multi.id as IDM,led_contratista_multi.tipo_contratista as TCM from led_contratistas inner join led_contratista_multi  on (led_contratistas.contratista=led_contratista_multi.contratista and led_contratistas.tipo_contratista!=led_contratista_multi.tipo_contratista)
  where led_contratista_multi.activo = 1
  and led_contratistas.estado_contratista='A'
  --and led_contratistas.cliente = 5546348
  --and led_contratistas.contratista = 5794
  order by led_contratistas.contratista


 OPEN C_Sync
 FETCH NEXT FROM C_Sync INTO @C,@TC,@CM,@IDM,@TCM
 WHILE @@fetch_status = 0
 BEGIN
  
  -- SELECT  @TC,getdate(),@C,@IDM
  UPDATE led_contratista_multi set tipo_contratista=@TC,modified=getdate() where contratista = @C and id=@IDM
  -- UPDATE led_contratista_multi set tipo_contratista=@TC,modified=getdate() where contratista = @TC and id=@IDM
  
  FETCH NEXT FROM C_Sync INTO @C,@TC,@CM,@IDM,@TCM
 END  
 CLOSE C_Sync
 DEALLOCATE C_Sync
END

GO

Used By

No items found