dbo.sp_alberti

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.sp_alberti 

AS

BEGIN

declare @id int = (select max(id_electoral) from alberti)
if (@id is null) set @id = 0

insert into alberti
       select top 100 p.identificacion as cuit, p.nombre_persona, a.documento, a.apellidos,a.nombres,a.direccion,b.localidad,a.provincia as cod_provincia,'BUENOS AIRES' as provincia,a.anio_nacimiento, a.id_electoral
      from padron_electoral a
      inner join padron_electoral_relacion b on 
            convert(int,b.distrito) = '2'
          and right('000'+b.SECCION,3) = right('000'+a.comuna,3) 
          and upper(right('00000'+b.CIRCUITO,5))  = upper(right('00000'+a.circuito_electoral,5))
          and convert(int,a.mesa) between b.MESADESDE and b.MESAHASTA
          and b.anio_padron = '2017' 
    left join padrones p on right('00000000'+p.cuerpo_clave,8) = right('00000000'+a.documento,8) and p.habilitado = 1 
    and PATINDEX('%' + a.apellidos + '%',p.nombre_persona) > 0 
    where a.provincia = '02'
      and id_electoral > 0
      and (b.localidad like '%ALBERTI %' 
           or b.localidad like '%ALBERTI'
           or b.localidad like '%DEL VISO%' 
        or b.localidad like '%LA LONJA%') 
        order by id_electoral

END 
/*
select top 100 a.documento, a.apellidos,a.nombres,a.direccion,a.anio_nacimiento, a.id_electoral
from padron_electoral a
where a.provincia = '02'
and id_electoral > 0 
order by id_electoral

select distinct provincia from padron_electoral where id_electoral between 
16223606 and 28466313
*/

GO

Used By

No items found