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_proceso | date | 3 | |
| @retomar | char | 1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.sp_procesos_nivel_socio_economico_bancos2
@cliente int = '263625984',
@fecha_proceso date = '2018-08-06',
@retomar char(1) = 'N'
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int,
@nombre varchar(100),
@identificador varchar(10),
@cuit varchar(20),
@rango_desde decimal(20,2),
@rango_hasta decimal(20,2),
@comex_importaciones decimal(20,2),
@comex_exportaciones decimal(20,2),
@facturacion decimal(20,2),
@es_cliente int ,
@es_cliente_sn bit
declare @domicilios table (id int, domicilio varchar(200), pai_nombre varchar(20), prv_nombre varchar(100), loc_nombre varchar(100), codpos varchar(10), tipo_domicilio varchar(10), created datetime)
declare @domicilio varchar(200),
@prv_nombre varchar(100),
@loc_nombre varchar(100),
@codpos varchar(10)
declare @telefonos table ( cuit varchar(20),
telefono varchar(max))
declare @tel varchar(max),
@cod_clae varchar(10),
@descripcion varchar(512),
@principal bit,
@formulario varchar(10),
@cant_empleados int
declare @empleados_cuit table (
hombres decimal(10,2),
mujeres decimal(10,2),
total decimal(10,2),
fecha varchar(10))
declare @ult_mes_bcra char(7)
declare @ult_mes_bcra2 char(7)
declare @cant_bcra int = 0
declare @monto_bcra decimal(16,2)
declare @monto decimal(16,2)
declare @bcra_temp table (codigo_ent int)
declare @p_codigo_ent int
declare @cuil varchar(20)
declare @fec_periodo_minimo varchar(11),
@periodo_minimo varchar(7)
set @fec_periodo_minimo = dateadd(MM, -23,getdate())
set @periodo_minimo = convert(varchar(4),DATEPART(yyyy,@fec_periodo_minimo))+right('0'+convert(varchar(2),DATEPART(mm,@fec_periodo_minimo)),2)
--> Inicio
if (@retomar = 'N')
begin
delete from procesos_nivel_socio_economico_bancos2 where cliente = @cliente and fecha_proceso = @fecha_proceso
end
DECLARE C_padron CURSOR FOR
select distinct /* top 10 */
r.id_padron,
r.nombre,
r.cuit
from procesos_nivel_socio_economico_respuesta r
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and cuit in
(
'30708737328',
'30651824938',
'30710089406',
'30575828856',
'30707538968',
'30708213469',
'30530589265',
'30708603658',
'30711999872',
'30690193422',
'33698986579',
'30506189345',
'30539148482',
'30628849893',
'30709186120',
'33686308389',
'33709116539',
'30590074965',
'30709836133',
'30710712758',
'30707542566',
'33710346939',
'30667805283',
'30708774681',
'30612323522',
'30666627926',
'30516453199',
'30629452822',
'30712408762',
'30528650003',
'30516644792',
'30999011345',
'33712295169',
'30701769801',
'30587876929',
'30649070918',
'30518449903',
'30714405698',
'33558762859',
'33650334499',
'30708640332',
'30691218410',
'33708207549',
'30565848441',
'30642009474',
'30707363874',
'30711590508',
'30697003742',
'33708937849',
'30713667508',
'33519697969',
'30594711722',
'30690137409',
'30708694173',
'33637552649',
'30685115359',
'30707835938',
'30605438462',
'30710022336',
'30593750856',
'30626831660',
'30503431153',
'30708578785',
'30505008401',
'30707415718',
'30547188760',
'30617644629',
'30707329552',
'30715196537',
'33558510809',
'30714765627',
'30709552267',
'30708773936',
'30708072490',
'30711204055',
'30638983253',
'33691629479',
'30500487379',
'30698376100',
'30639518600',
'30708775947',
'30708883073',
'30707338977',
'30709171190',
'30709230812',
'30708739169',
'30649768974',
'30611385680',
'30707807810',
'30709810770',
'30618555840',
'30709035262',
'33505110809',
'30646362675',
'30714984027',
'30710399286',
'30598204310',
'30715069357',
'30677350535',
'30648722563',
'30707927425',
'30709192384',
'30711622930',
'30679128651',
'33707367569',
'30680640919',
'33713713509',
'30711470804',
'30699169575',
'30516580816',
'30506746864',
'30517445734',
'30500741038',
'30708454865',
'30602330733',
'30687182959',
'30708242418',
'30526008835',
'33711012309',
'30708992743',
'30696143567',
'30701150119',
'30535981929',
'30697309264',
'30643914278',
'30663253529',
'30707901957',
'30710163819',
'30516938133',
'30588303035',
'30710303270',
'30714504742',
'30612256574',
'30691659840',
'30690762648',
'30521574956',
'30500050795',
'33711913829',
'30710007523',
'30666525791',
'33545736689',
'30638340689',
'30619391094',
'30707656480',
'30714605344',
'30676538921',
'30557237344',
'30501227583',
'30710065744',
'33707261329',
'30689686148',
'30711790426',
'33701008869',
'30709012041',
'30708600187',
'30713998008',
'30680754914',
'30708410051',
'30645330184',
'30709351962',
'33626043149',
'30709871834',
'30704747183',
'30708691190',
'30711951306',
'30503115812',
'30630617762',
'30707069577',
'30709004081',
'30708615052',
'30500059490',
'30501544430',
'30708465697',
'30536937435',
'30708385081',
'30645473325',
'30710630956',
'30596669723',
'30600659177',
'30711183503',
'33710591429',
'30709451401',
'30707063854',
'30708910003',
'30709681954',
'30681189897',
'30626109930',
'30640335870',
'30608149607',
'30501120479',
'30708320133',
'30680802447',
'30707818057',
'30500090886',
'30711597650',
'30504819678',
'30708169524',
'30504970651',
'33516913679',
'30707937382',
'30693212657',
'33708567189',
'30677774971',
'33708103409',
'30709717940',
'30526370542',
'33709291489',
'30709177962',
'30660840199',
'30659795295',
'30694805627',
'33708606559',
'30570021342',
'30709273465',
'30695307485',
'30627213146',
'33707961169',
'30500229973',
'33685198369',
'33584584179',
'30710966318',
'30698322337',
'30583540500',
'30578341087',
'30687108406',
'30679568309',
'30696199317',
'30507119235',
'30545714260',
'30552483304',
'30704440819',
'30710309201',
'30503825984',
'30694811767',
'30550925555',
'30708118830',
'30710981724',
'30709251534',
'30711067244',
'30518954241',
'30710301790',
'30699998008',
'30632196705',
'30685140779',
'33711753309',
'30500716858',
'30696285191',
'30710178298',
'30711331626',
'30616131776',
'30707473807',
'30506763165',
'30710028830',
'30711327661',
'30617888005',
'30707191887',
'30709045349',
'30710106548',
'30616696684',
'30708202025',
'30708499850',
'33708306229',
'30584042741',
'33506288059',
'30710555393',
'30656561528',
'30710749309',
'30708619945',
'30682415513',
'33666611719',
'30625195353',
'30574096215',
'30555720919',
'30709282537',
'30523023213',
'30557556652',
'30640854274',
'30688627563',
'33663293309',
'30677320784',
'30640256741',
'30696164203',
'30709653497',
'30709310336',
'30684945358',
'30636197153',
'30708530146',
'33708131259',
'30710880995',
'30708204796',
'33707436749',
'30577801114',
'30714971758',
'30696977115',
'30599447918',
'30612903901',
'30714763217',
'30709115126',
'30708600977',
'30682335706',
'30690011499',
'30708714409',
'30504287269',
'30550974203',
'30707441514',
'30691161427',
'30521197702',
'30709339350',
'30710807651',
'30714186031',
'30520152691',
'30712949801',
'30710362358')
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @id_padron,
@nombre,
@cuit
WHILE @@fetch_status = 0
BEGIN
--> BANCOS: Ultimo mes BCRA
set @ult_mes_bcra = (select max(fec_inf) from cendeu where iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
set @ult_mes_bcra2 = (select max(fec_inf) from cendeu_temp where iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
if (@ult_mes_bcra is null) set @ult_mes_bcra = '200101'
if (@ult_mes_bcra2 is null) set @ult_mes_bcra2 = '200101'
if (@ult_mes_bcra2 > @ult_mes_bcra) begin set @ult_mes_bcra = @ult_mes_bcra2 end
insert into procesos_nivel_socio_economico_bancos2
select distinct @cliente, @fecha_proceso, @id_padron,
iden as cuit,
SUBSTRING(@ult_mes_bcra,1,4) + '-' + SUBSTRING(@ult_mes_bcra,5,2) as periodo,
isnull(nombre_corto,nombre) as banco,
substring(convert(char(2),convert(int,cendeu.situacion)),1,1) as situacion,
((prestamos+particip+garotor+o_cptos+deuda_total)*1000) as deuda,
1 as visible
from cendeu inner join EntidadesBancarias on
convert(int,cendeu.codigo_ent) = EntidadesBancarias.id_banco
where iden = @cuit
and fec_inf = @ult_mes_bcra
and vigente = 1
and not exists (select * from cendeu b where b.iden = cendeu.iden and cast(b.codigo_ent as int) = cast(cendeu.codigo_ent as int) and b.fec_inf = cendeu.fec_inf and b.vigente = 1 and b.id_fuente = 2 and b.id_cendeu != cendeu.id_cendeu)
and not exists (select * from cendeu c
where c.iden = cendeu.iden
and cast(c.codigo_ent as int) = cast(cendeu.codigo_ent as int)
and c.fec_inf = cendeu.fec_inf
and c.vigente = cendeu.vigente
and (isnull(c.id_fuente,1)) = (isnull(cendeu.id_fuente,1))
and c.id_cendeu < cendeu.id_cendeu)
union all
select distinct @cliente, @fecha_proceso, @id_padron,
iden as cuit,
SUBSTRING(@ult_mes_bcra,1,4) + '-' + SUBSTRING(@ult_mes_bcra,5,2) as periodo,
isnull(nombre_corto,nombre) as banco,
substring(convert(char(2),convert(int,cendeu_temp.situacion)),1,1) as situacion,
((prestamos+particip+garotor+o_cptos+deuda_total)*1000) as deuda,
1 as visible
from cendeu_temp inner join EntidadesBancarias on
convert(int,cendeu_temp.codigo_ent) = EntidadesBancarias.id_banco
where iden = @cuit
and fec_inf = @ult_mes_bcra
and vigente = 1
and not exists (select * from cendeu b where b.iden = cendeu_temp.iden and cast(b.codigo_ent as int) = cast(cendeu_temp.codigo_ent as int) and b.fec_inf = cendeu_temp.fec_inf and b.vigente = 1 and b.id_fuente = 2 and b.id_cendeu != cendeu_temp.id_cendeu)
and not exists (select * from cendeu_temp c
where c.iden = cendeu_temp.iden
and cast(c.codigo_ent as int) = cast(cendeu_temp.codigo_ent as int)
and c.fec_inf = cendeu_temp.fec_inf
and c.vigente = cendeu_temp.vigente
and (isnull(c.id_fuente,1)) = (isnull(cendeu_temp.id_fuente,1))
and c.id_cendeu < cendeu_temp.id_cendeu)
--> Es cliente
set @fec_periodo_minimo = dateadd(MM, -23,getdate())
set @periodo_minimo = convert(varchar(4),DATEPART(yyyy,@fec_periodo_minimo))+right('0'+convert(varchar(2),DATEPART(mm,@fec_periodo_minimo)),2)
set @es_cliente = (select count(*) from cendeu_temp where convert(int,codigo_ent) in (285) and iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
if(@es_cliente = 0)
begin
set @es_cliente = (select count(*) from cendeu where convert(int,codigo_ent) in (285) and iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
end
set @es_cliente_sn = 0
if (@es_cliente > 0) set @es_cliente_sn = 1
update procesos_nivel_socio_economico set es_cliente = @es_cliente_sn where cuit = @cuit
FETCH NEXT FROM C_Padron INTO @id_padron,
@nombre,
@cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.sp_procesos_nivel_socio_economico_bancos2
@cliente int = '263625984',
@fecha_proceso date = '2018-08-06',
@retomar char(1) = 'N'
AS
BEGIN
SET NOCOUNT ON;
declare @id_padron int,
@nombre varchar(100),
@identificador varchar(10),
@cuit varchar(20),
@rango_desde decimal(20,2),
@rango_hasta decimal(20,2),
@comex_importaciones decimal(20,2),
@comex_exportaciones decimal(20,2),
@facturacion decimal(20,2),
@es_cliente int ,
@es_cliente_sn bit
declare @domicilios table (id int, domicilio varchar(200), pai_nombre varchar(20), prv_nombre varchar(100), loc_nombre varchar(100), codpos varchar(10), tipo_domicilio varchar(10), created datetime)
declare @domicilio varchar(200),
@prv_nombre varchar(100),
@loc_nombre varchar(100),
@codpos varchar(10)
declare @telefonos table ( cuit varchar(20),
telefono varchar(max))
declare @tel varchar(max),
@cod_clae varchar(10),
@descripcion varchar(512),
@principal bit,
@formulario varchar(10),
@cant_empleados int
declare @empleados_cuit table (
hombres decimal(10,2),
mujeres decimal(10,2),
total decimal(10,2),
fecha varchar(10))
declare @ult_mes_bcra char(7)
declare @ult_mes_bcra2 char(7)
declare @cant_bcra int = 0
declare @monto_bcra decimal(16,2)
declare @monto decimal(16,2)
declare @bcra_temp table (codigo_ent int)
declare @p_codigo_ent int
declare @cuil varchar(20)
declare @fec_periodo_minimo varchar(11),
@periodo_minimo varchar(7)
set @fec_periodo_minimo = dateadd(MM, -23,getdate())
set @periodo_minimo = convert(varchar(4),DATEPART(yyyy,@fec_periodo_minimo))+right('0'+convert(varchar(2),DATEPART(mm,@fec_periodo_minimo)),2)
--> Inicio
if (@retomar = 'N')
begin
delete from procesos_nivel_socio_economico_bancos2 where cliente = @cliente and fecha_proceso = @fecha_proceso
end
DECLARE C_padron CURSOR FOR
select distinct /* top 10 */
r.id_padron,
r.nombre,
r.cuit
from procesos_nivel_socio_economico_respuesta r
where cliente = @cliente
and fecha_proceso = @fecha_proceso
and cuit in
(
'30708737328',
'30651824938',
'30710089406',
'30575828856',
'30707538968',
'30708213469',
'30530589265',
'30708603658',
'30711999872',
'30690193422',
'33698986579',
'30506189345',
'30539148482',
'30628849893',
'30709186120',
'33686308389',
'33709116539',
'30590074965',
'30709836133',
'30710712758',
'30707542566',
'33710346939',
'30667805283',
'30708774681',
'30612323522',
'30666627926',
'30516453199',
'30629452822',
'30712408762',
'30528650003',
'30516644792',
'30999011345',
'33712295169',
'30701769801',
'30587876929',
'30649070918',
'30518449903',
'30714405698',
'33558762859',
'33650334499',
'30708640332',
'30691218410',
'33708207549',
'30565848441',
'30642009474',
'30707363874',
'30711590508',
'30697003742',
'33708937849',
'30713667508',
'33519697969',
'30594711722',
'30690137409',
'30708694173',
'33637552649',
'30685115359',
'30707835938',
'30605438462',
'30710022336',
'30593750856',
'30626831660',
'30503431153',
'30708578785',
'30505008401',
'30707415718',
'30547188760',
'30617644629',
'30707329552',
'30715196537',
'33558510809',
'30714765627',
'30709552267',
'30708773936',
'30708072490',
'30711204055',
'30638983253',
'33691629479',
'30500487379',
'30698376100',
'30639518600',
'30708775947',
'30708883073',
'30707338977',
'30709171190',
'30709230812',
'30708739169',
'30649768974',
'30611385680',
'30707807810',
'30709810770',
'30618555840',
'30709035262',
'33505110809',
'30646362675',
'30714984027',
'30710399286',
'30598204310',
'30715069357',
'30677350535',
'30648722563',
'30707927425',
'30709192384',
'30711622930',
'30679128651',
'33707367569',
'30680640919',
'33713713509',
'30711470804',
'30699169575',
'30516580816',
'30506746864',
'30517445734',
'30500741038',
'30708454865',
'30602330733',
'30687182959',
'30708242418',
'30526008835',
'33711012309',
'30708992743',
'30696143567',
'30701150119',
'30535981929',
'30697309264',
'30643914278',
'30663253529',
'30707901957',
'30710163819',
'30516938133',
'30588303035',
'30710303270',
'30714504742',
'30612256574',
'30691659840',
'30690762648',
'30521574956',
'30500050795',
'33711913829',
'30710007523',
'30666525791',
'33545736689',
'30638340689',
'30619391094',
'30707656480',
'30714605344',
'30676538921',
'30557237344',
'30501227583',
'30710065744',
'33707261329',
'30689686148',
'30711790426',
'33701008869',
'30709012041',
'30708600187',
'30713998008',
'30680754914',
'30708410051',
'30645330184',
'30709351962',
'33626043149',
'30709871834',
'30704747183',
'30708691190',
'30711951306',
'30503115812',
'30630617762',
'30707069577',
'30709004081',
'30708615052',
'30500059490',
'30501544430',
'30708465697',
'30536937435',
'30708385081',
'30645473325',
'30710630956',
'30596669723',
'30600659177',
'30711183503',
'33710591429',
'30709451401',
'30707063854',
'30708910003',
'30709681954',
'30681189897',
'30626109930',
'30640335870',
'30608149607',
'30501120479',
'30708320133',
'30680802447',
'30707818057',
'30500090886',
'30711597650',
'30504819678',
'30708169524',
'30504970651',
'33516913679',
'30707937382',
'30693212657',
'33708567189',
'30677774971',
'33708103409',
'30709717940',
'30526370542',
'33709291489',
'30709177962',
'30660840199',
'30659795295',
'30694805627',
'33708606559',
'30570021342',
'30709273465',
'30695307485',
'30627213146',
'33707961169',
'30500229973',
'33685198369',
'33584584179',
'30710966318',
'30698322337',
'30583540500',
'30578341087',
'30687108406',
'30679568309',
'30696199317',
'30507119235',
'30545714260',
'30552483304',
'30704440819',
'30710309201',
'30503825984',
'30694811767',
'30550925555',
'30708118830',
'30710981724',
'30709251534',
'30711067244',
'30518954241',
'30710301790',
'30699998008',
'30632196705',
'30685140779',
'33711753309',
'30500716858',
'30696285191',
'30710178298',
'30711331626',
'30616131776',
'30707473807',
'30506763165',
'30710028830',
'30711327661',
'30617888005',
'30707191887',
'30709045349',
'30710106548',
'30616696684',
'30708202025',
'30708499850',
'33708306229',
'30584042741',
'33506288059',
'30710555393',
'30656561528',
'30710749309',
'30708619945',
'30682415513',
'33666611719',
'30625195353',
'30574096215',
'30555720919',
'30709282537',
'30523023213',
'30557556652',
'30640854274',
'30688627563',
'33663293309',
'30677320784',
'30640256741',
'30696164203',
'30709653497',
'30709310336',
'30684945358',
'30636197153',
'30708530146',
'33708131259',
'30710880995',
'30708204796',
'33707436749',
'30577801114',
'30714971758',
'30696977115',
'30599447918',
'30612903901',
'30714763217',
'30709115126',
'30708600977',
'30682335706',
'30690011499',
'30708714409',
'30504287269',
'30550974203',
'30707441514',
'30691161427',
'30521197702',
'30709339350',
'30710807651',
'30714186031',
'30520152691',
'30712949801',
'30710362358')
OPEN C_Padron
FETCH NEXT FROM C_Padron INTO @id_padron,
@nombre,
@cuit
WHILE @@fetch_status = 0
BEGIN
--> BANCOS: Ultimo mes BCRA
set @ult_mes_bcra = (select max(fec_inf) from cendeu where iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
set @ult_mes_bcra2 = (select max(fec_inf) from cendeu_temp where iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
if (@ult_mes_bcra is null) set @ult_mes_bcra = '200101'
if (@ult_mes_bcra2 is null) set @ult_mes_bcra2 = '200101'
if (@ult_mes_bcra2 > @ult_mes_bcra) begin set @ult_mes_bcra = @ult_mes_bcra2 end
insert into procesos_nivel_socio_economico_bancos2
select distinct @cliente, @fecha_proceso, @id_padron,
iden as cuit,
SUBSTRING(@ult_mes_bcra,1,4) + '-' + SUBSTRING(@ult_mes_bcra,5,2) as periodo,
isnull(nombre_corto,nombre) as banco,
substring(convert(char(2),convert(int,cendeu.situacion)),1,1) as situacion,
((prestamos+particip+garotor+o_cptos+deuda_total)*1000) as deuda,
1 as visible
from cendeu inner join EntidadesBancarias on
convert(int,cendeu.codigo_ent) = EntidadesBancarias.id_banco
where iden = @cuit
and fec_inf = @ult_mes_bcra
and vigente = 1
and not exists (select * from cendeu b where b.iden = cendeu.iden and cast(b.codigo_ent as int) = cast(cendeu.codigo_ent as int) and b.fec_inf = cendeu.fec_inf and b.vigente = 1 and b.id_fuente = 2 and b.id_cendeu != cendeu.id_cendeu)
and not exists (select * from cendeu c
where c.iden = cendeu.iden
and cast(c.codigo_ent as int) = cast(cendeu.codigo_ent as int)
and c.fec_inf = cendeu.fec_inf
and c.vigente = cendeu.vigente
and (isnull(c.id_fuente,1)) = (isnull(cendeu.id_fuente,1))
and c.id_cendeu < cendeu.id_cendeu)
union all
select distinct @cliente, @fecha_proceso, @id_padron,
iden as cuit,
SUBSTRING(@ult_mes_bcra,1,4) + '-' + SUBSTRING(@ult_mes_bcra,5,2) as periodo,
isnull(nombre_corto,nombre) as banco,
substring(convert(char(2),convert(int,cendeu_temp.situacion)),1,1) as situacion,
((prestamos+particip+garotor+o_cptos+deuda_total)*1000) as deuda,
1 as visible
from cendeu_temp inner join EntidadesBancarias on
convert(int,cendeu_temp.codigo_ent) = EntidadesBancarias.id_banco
where iden = @cuit
and fec_inf = @ult_mes_bcra
and vigente = 1
and not exists (select * from cendeu b where b.iden = cendeu_temp.iden and cast(b.codigo_ent as int) = cast(cendeu_temp.codigo_ent as int) and b.fec_inf = cendeu_temp.fec_inf and b.vigente = 1 and b.id_fuente = 2 and b.id_cendeu != cendeu_temp.id_cendeu)
and not exists (select * from cendeu_temp c
where c.iden = cendeu_temp.iden
and cast(c.codigo_ent as int) = cast(cendeu_temp.codigo_ent as int)
and c.fec_inf = cendeu_temp.fec_inf
and c.vigente = cendeu_temp.vigente
and (isnull(c.id_fuente,1)) = (isnull(cendeu_temp.id_fuente,1))
and c.id_cendeu < cendeu_temp.id_cendeu)
--> Es cliente
set @fec_periodo_minimo = dateadd(MM, -23,getdate())
set @periodo_minimo = convert(varchar(4),DATEPART(yyyy,@fec_periodo_minimo))+right('0'+convert(varchar(2),DATEPART(mm,@fec_periodo_minimo)),2)
set @es_cliente = (select count(*) from cendeu_temp where convert(int,codigo_ent) in (285) and iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
if(@es_cliente = 0)
begin
set @es_cliente = (select count(*) from cendeu where convert(int,codigo_ent) in (285) and iden = @cuit and vigente = 1 and fec_inf >= @periodo_minimo)
end
set @es_cliente_sn = 0
if (@es_cliente > 0) set @es_cliente_sn = 1
update procesos_nivel_socio_economico set es_cliente = @es_cliente_sn where cuit = @cuit
FETCH NEXT FROM C_Padron INTO @id_padron,
@nombre,
@cuit
END
CLOSE C_Padron
DEALLOCATE C_Padron
END
GO
Depends On
5Used By
No items found