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
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
/**
EXEC OS_ACTIVOS_2_DATOS_PERSONAS
select count(*) from obrassocial_activos where _datos_personas_proc = 1
**/
-- =============================================
CREATE OR ALTER PROCEDURE dbo.OS_ACTIVOS_2_DATOS_PERSONAS
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DECLARE @cuit varchar(50)
DECLARE @fecha_nac date
DECLARE @sexo varchar(1)
DECLARE @cuit_persona varchar(50)
DECLARE OBRASSOC_ACT CURSOR FOR
select top 100000 Cuil_Activo as cuit,
datefromparts(right(convert(varchar(10),obrassocial_activos.FechaNac),4),
substring(convert(varchar(10),obrassocial_activos.FechaNac),4,2),
left(convert(varchar(10),obrassocial_activos.FechaNac),2)) as fecha_nac,
left(obrassocial_activos.sexo, 1) as sexo,
DATOS_PERSONAS.c01_cuit
from obrassocial_activos left join datos_personas
on datos_personas.c01_cuit = obrassocial_activos.Cuil_Activo
where c02_fecha_nac is null
and ISNULL(obrassocial_activos._datos_personas_proc, 0) = 0
OPEN OBRASSOC_ACT
FETCH NEXT FROM OBRASSOC_ACT INTO @cuit, @fecha_nac, @sexo, @cuit_persona
WHILE @@FETCH_STATUS = 0 BEGIN
if (@cuit_persona is not null) begin
update DATOS_PERSONAS SET c02_fecha_nac = @fecha_nac
where c01_cuit = @cuit
end
else begin
insert into DATOS_PERSONAS (c01_cuit, c02_fecha_nac) values (@cuit, @fecha_nac)
end
if not exists (select cuit from padrones_sexo_update where cuit = @cuit) begin
insert into padrones_sexo_update (cuit, sexo) values (@cuit, @sexo)
end
update obrassocial_activos set _datos_personas_proc = 1 where Cuil_Activo = @cuit
FETCH NEXT FROM OBRASSOC_ACT INTO @cuit, @fecha_nac, @sexo, @cuit_persona
END
CLOSE OBRASSOC_ACT
DEALLOCATE OBRASSOC_ACT
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
/**
EXEC OS_ACTIVOS_2_DATOS_PERSONAS
select count(*) from obrassocial_activos where _datos_personas_proc = 1
**/
-- =============================================
CREATE OR ALTER PROCEDURE dbo.OS_ACTIVOS_2_DATOS_PERSONAS
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DECLARE @cuit varchar(50)
DECLARE @fecha_nac date
DECLARE @sexo varchar(1)
DECLARE @cuit_persona varchar(50)
DECLARE OBRASSOC_ACT CURSOR FOR
select top 100000 Cuil_Activo as cuit,
datefromparts(right(convert(varchar(10),obrassocial_activos.FechaNac),4),
substring(convert(varchar(10),obrassocial_activos.FechaNac),4,2),
left(convert(varchar(10),obrassocial_activos.FechaNac),2)) as fecha_nac,
left(obrassocial_activos.sexo, 1) as sexo,
DATOS_PERSONAS.c01_cuit
from obrassocial_activos left join datos_personas
on datos_personas.c01_cuit = obrassocial_activos.Cuil_Activo
where c02_fecha_nac is null
and ISNULL(obrassocial_activos._datos_personas_proc, 0) = 0
OPEN OBRASSOC_ACT
FETCH NEXT FROM OBRASSOC_ACT INTO @cuit, @fecha_nac, @sexo, @cuit_persona
WHILE @@FETCH_STATUS = 0 BEGIN
if (@cuit_persona is not null) begin
update DATOS_PERSONAS SET c02_fecha_nac = @fecha_nac
where c01_cuit = @cuit
end
else begin
insert into DATOS_PERSONAS (c01_cuit, c02_fecha_nac) values (@cuit, @fecha_nac)
end
if not exists (select cuit from padrones_sexo_update where cuit = @cuit) begin
insert into padrones_sexo_update (cuit, sexo) values (@cuit, @sexo)
end
update obrassocial_activos set _datos_personas_proc = 1 where Cuil_Activo = @cuit
FETCH NEXT FROM OBRASSOC_ACT INTO @cuit, @fecha_nac, @sexo, @cuit_persona
END
CLOSE OBRASSOC_ACT
DEALLOCATE OBRASSOC_ACT
END
GO
Used By
No items found