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.actualizar_emails
AS
BEGIN
SET NOCOUNT ON;
declare @cuil varchar(20)
declare @id bigint
declare @email varchar(1000)
declare @cant int = 0
declare @IDP int
DECLARE C_padron CURSOR FOR
select top 15000 a.cuil, lower(a.email) as email, a.idreg, p.id_padron
from empleados_Abril_2021 a
inner join padrones p on (a.CUIL=p.identificacion and p.habilitado=1 and p.identificador in (select identificador from identificadores where country_code = 'AR'))
where isnull(proceso_email,0) = 0 and len(a.email) > 3
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @cuil, @email, @id,@IDP
WHILE @@fetch_status = 0
BEGIN
set @cant = @cant + 1
if not exists (select * from emails where id_padron = @IDP
and tipo = 'ANSES'
and email = @email)
begin
insert into emails (id_padron, email, tipo, created)
values (@IDP, @email, 'ANSES', getdate())
end
update empleados_Abril_2021
set fecha_proceso_email = getdate(), proceso_email = 1
where idreg = @id
FETCH NEXT FROM C_Padron INTO @cuil, @email, @id,@IDP
END
CLOSE C_Padron
DEALLOCATE C_Padron
select @cant as cantidad
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.actualizar_emails
AS
BEGIN
SET NOCOUNT ON;
declare @cuil varchar(20)
declare @id bigint
declare @email varchar(1000)
declare @cant int = 0
declare @IDP int
DECLARE C_padron CURSOR FOR
select top 15000 a.cuil, lower(a.email) as email, a.idreg, p.id_padron
from empleados_Abril_2021 a
inner join padrones p on (a.CUIL=p.identificacion and p.habilitado=1 and p.identificador in (select identificador from identificadores where country_code = 'AR'))
where isnull(proceso_email,0) = 0 and len(a.email) > 3
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @cuil, @email, @id,@IDP
WHILE @@fetch_status = 0
BEGIN
set @cant = @cant + 1
if not exists (select * from emails where id_padron = @IDP
and tipo = 'ANSES'
and email = @email)
begin
insert into emails (id_padron, email, tipo, created)
values (@IDP, @email, 'ANSES', getdate())
end
update empleados_Abril_2021
set fecha_proceso_email = getdate(), proceso_email = 1
where idreg = @id
FETCH NEXT FROM C_Padron INTO @cuil, @email, @id,@IDP
END
CLOSE C_Padron
DEALLOCATE C_Padron
select @cant as cantidad
END
GO
Used By
No items found