Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
2| Name | Data Type | Length | Description |
|---|---|---|---|
| @cliente | int | 4 | |
| @fecha_proceso | date | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
CUIT
RAZON SOCIAL
DOMICILIO COMPLETO
DATOS DE TELEFONO
ACTIVIDAD
FACTURACION
DEUDA EN EL SISTEMA FINANCIERO Y SITUACION (ultima actualizada de BCRA) con apertura de líneas y bancos
CAPITAS EN ANSES (últimos 3 meses)
OPERATORIA DE COMEX (impo/expo, monto últimos 6 meses)
MARCA DE SI ES O NO CLIENTE MACRO
Datos de 5 Mayores sueldos de la nómina (cuit y datos de contacto-tel o celular)
*/
/*
[sp_procesos_nivel_socio_economico] '263625984', '2018-08-06', 'N'
[sp_procesos_nivel_socio_economico] '263625984', '2018-08-06', 'S'
*/
CREATE OR ALTER procedure dbo.sp_procesos_nivel_socio_economico_telefonos_todos
@cliente int = '263625984',
@fecha_proceso date = '2018-08-06'
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int,
@cuit varchar(20),
@cuil varchar(20),
@tel varchar(max)
declare @telefonos table ( cuit varchar(20),
telefono varchar(max))
/*
--> Telefonos Empresa
DECLARE C_padron CURSOR FOR
select distinct id_padron, cuit
from procesos_nivel_socio_economico_respuesta
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and ISNULL(telefonos,'') = ''
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @id_padron, @cuit
WHILE @@fetch_status = 0
BEGIN
set @tel = ''
insert into @telefonos
exec sp_obtener_telefonos @cuit
set @tel = (select telefono from @telefonos)
delete from @telefonos
if (@tel='') set @tel = null
if (@tel is not null)
begin
update procesos_nivel_socio_economico_respuesta
set telefonos = @tel
where id_padron = @id_padron
end
FETCH NEXT FROM C_Padron INTO @id_padron, @cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
*/
--> Telefonos empleados
DECLARE C_tel_empleados CURSOR FOR
select distinct id_padron, cuil
from procesos_nivel_socio_economico_empleados_2
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and ISNULL(telefono,'') = ''
OPEN C_tel_empleados
FETCH NEXT FROM C_tel_empleados INTO @id_padron, @cuil
WHILE @@fetch_status = 0
BEGIN
insert into @telefonos
exec sp_obtener_telefonos @cuil
set @tel = (select telefono from @telefonos)
delete from @telefonos
if (@tel='') set @tel = null
if (@tel is not null)
begin
update procesos_nivel_socio_economico_empleados_2
set telefono = @tel
where cliente = @cliente and fecha_proceso = @fecha_proceso and id_padron = @id_padron and cuil = @cuil
end
FETCH NEXT FROM C_tel_empleados INTO @id_padron, @cuil
END
CLOSE C_tel_empleados
DEALLOCATE C_tel_empleados
END
GO
GO
/*
CUIT
RAZON SOCIAL
DOMICILIO COMPLETO
DATOS DE TELEFONO
ACTIVIDAD
FACTURACION
DEUDA EN EL SISTEMA FINANCIERO Y SITUACION (ultima actualizada de BCRA) con apertura de líneas y bancos
CAPITAS EN ANSES (últimos 3 meses)
OPERATORIA DE COMEX (impo/expo, monto últimos 6 meses)
MARCA DE SI ES O NO CLIENTE MACRO
Datos de 5 Mayores sueldos de la nómina (cuit y datos de contacto-tel o celular)
*/
/*
[sp_procesos_nivel_socio_economico] '263625984', '2018-08-06', 'N'
[sp_procesos_nivel_socio_economico] '263625984', '2018-08-06', 'S'
*/
CREATE OR ALTER procedure dbo.sp_procesos_nivel_socio_economico_telefonos_todos
@cliente int = '263625984',
@fecha_proceso date = '2018-08-06'
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int,
@cuit varchar(20),
@cuil varchar(20),
@tel varchar(max)
declare @telefonos table ( cuit varchar(20),
telefono varchar(max))
/*
--> Telefonos Empresa
DECLARE C_padron CURSOR FOR
select distinct id_padron, cuit
from procesos_nivel_socio_economico_respuesta
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and ISNULL(telefonos,'') = ''
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @id_padron, @cuit
WHILE @@fetch_status = 0
BEGIN
set @tel = ''
insert into @telefonos
exec sp_obtener_telefonos @cuit
set @tel = (select telefono from @telefonos)
delete from @telefonos
if (@tel='') set @tel = null
if (@tel is not null)
begin
update procesos_nivel_socio_economico_respuesta
set telefonos = @tel
where id_padron = @id_padron
end
FETCH NEXT FROM C_Padron INTO @id_padron, @cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
*/
--> Telefonos empleados
DECLARE C_tel_empleados CURSOR FOR
select distinct id_padron, cuil
from procesos_nivel_socio_economico_empleados_2
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and ISNULL(telefono,'') = ''
OPEN C_tel_empleados
FETCH NEXT FROM C_tel_empleados INTO @id_padron, @cuil
WHILE @@fetch_status = 0
BEGIN
insert into @telefonos
exec sp_obtener_telefonos @cuil
set @tel = (select telefono from @telefonos)
delete from @telefonos
if (@tel='') set @tel = null
if (@tel is not null)
begin
update procesos_nivel_socio_economico_empleados_2
set telefono = @tel
where cliente = @cliente and fecha_proceso = @fecha_proceso and id_padron = @id_padron and cuil = @cuil
end
FETCH NEXT FROM C_tel_empleados INTO @id_padron, @cuil
END
CLOSE C_tel_empleados
DEALLOCATE C_tel_empleados
END
GO
Used By
No items found