Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @cliente | int | 4 | |
| @fecha | date | 3 | |
| @cuit_desde | varchar | 20 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec [sp_procesos_cuits_homonimos_sociedades] 2046807993,'2024-03-01', '30580463998'
*/
CREATE OR ALTER PROCEDURE dbo.sp_procesos_cuits_homonimos_sociedades
@cliente int = 2,
@fecha date = '2023-03-01',
@cuit_desde varchar(20) = ''
AS
BEGIN
SET NOCOUNT ON;
declare @cuit varchar(20)
declare @nombre varchar(1000)
declare @nombre1 varchar(MAX)
if (@cuit_desde is null) set @cuit_desde = ''
DECLARE C_padron_2 CURSOR FOR
select distinct a.cuit, p.nombre_persona
from procesos_cuit a
inner join padrones p on p.identificacion = a.cuit and p.habilitado = 1
where a.cliente = @cliente
and a.fecha = @fecha
and a.cuit > @cuit_desde
and not exists (select * from procesos_cuit_edictos_homonimos j where j.cliente = @cliente and j.fecha = @fecha and j.cuit = a.cuit)
order by a.cuit
OPEN C_Padron_2
FETCH NEXT FROM C_Padron_2 INTO @cuit, @nombre1
WHILE @@fetch_status = 0
BEGIN
set @nombre = '"*' + replace(@nombre1, ' ', '*" NEAR "*') + '*"';
-- EDICTOS
insert into [procesos_cuit_edictos_homonimos]
select distinct @cliente, @fecha, @cuit, @nombre1,
razon_social,
domicilio_sociedad,
localidad_sociedad_cod,
localidad_sociedad,
provincia_sociedad,
provincia_sociedad_cod,
provincia_boletin,
fecha_publicacion,
titulo,
tipo_publicacion,
capita_social,
fecha_constitucion,
cargo,
nombre_integrante,
documento_integrante,
domicilio_integrante,
localidad_integrante_cod,
localidad_integrante,
provincia_integrante,
nacionalidad_int,
estado_civil_int,
fecha_nacimiento_int,
tipodoc_int,
nrdoc_int,
cuit_int,
profesion_int,
provincia_int,
cargo_int,
duracion,
convert(varchar(max),objeto),
fuente,
codigo_archivo,
convert(varchar(max),contenido_archivo),
cuit_integrante,
tipo_publicacion_2
from sociedades_constituciones
where contains((razon_social),@nombre) and ISNULL(documento_soc, '') = ''
FETCH NEXT FROM C_Padron_2 INTO @cuit, @nombre1
END
CLOSE C_Padron_2
DEALLOCATE C_Padron_2
select * from [procesos_cuit_edictos_homonimos] where cliente = @cliente and fecha = @fecha
END
GO
GO
/*
exec [sp_procesos_cuits_homonimos_sociedades] 2046807993,'2024-03-01', '30580463998'
*/
CREATE OR ALTER PROCEDURE dbo.sp_procesos_cuits_homonimos_sociedades
@cliente int = 2,
@fecha date = '2023-03-01',
@cuit_desde varchar(20) = ''
AS
BEGIN
SET NOCOUNT ON;
declare @cuit varchar(20)
declare @nombre varchar(1000)
declare @nombre1 varchar(MAX)
if (@cuit_desde is null) set @cuit_desde = ''
DECLARE C_padron_2 CURSOR FOR
select distinct a.cuit, p.nombre_persona
from procesos_cuit a
inner join padrones p on p.identificacion = a.cuit and p.habilitado = 1
where a.cliente = @cliente
and a.fecha = @fecha
and a.cuit > @cuit_desde
and not exists (select * from procesos_cuit_edictos_homonimos j where j.cliente = @cliente and j.fecha = @fecha and j.cuit = a.cuit)
order by a.cuit
OPEN C_Padron_2
FETCH NEXT FROM C_Padron_2 INTO @cuit, @nombre1
WHILE @@fetch_status = 0
BEGIN
set @nombre = '"*' + replace(@nombre1, ' ', '*" NEAR "*') + '*"';
-- EDICTOS
insert into [procesos_cuit_edictos_homonimos]
select distinct @cliente, @fecha, @cuit, @nombre1,
razon_social,
domicilio_sociedad,
localidad_sociedad_cod,
localidad_sociedad,
provincia_sociedad,
provincia_sociedad_cod,
provincia_boletin,
fecha_publicacion,
titulo,
tipo_publicacion,
capita_social,
fecha_constitucion,
cargo,
nombre_integrante,
documento_integrante,
domicilio_integrante,
localidad_integrante_cod,
localidad_integrante,
provincia_integrante,
nacionalidad_int,
estado_civil_int,
fecha_nacimiento_int,
tipodoc_int,
nrdoc_int,
cuit_int,
profesion_int,
provincia_int,
cargo_int,
duracion,
convert(varchar(max),objeto),
fuente,
codigo_archivo,
convert(varchar(max),contenido_archivo),
cuit_integrante,
tipo_publicacion_2
from sociedades_constituciones
where contains((razon_social),@nombre) and ISNULL(documento_soc, '') = ''
FETCH NEXT FROM C_Padron_2 INTO @cuit, @nombre1
END
CLOSE C_Padron_2
DEALLOCATE C_Padron_2
select * from [procesos_cuit_edictos_homonimos] where cliente = @cliente and fecha = @fecha
END
GO
Depends On
4Used By
No items found