dbo.pe_obtener_cuits

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

4
Name Data Type Length Description
@cliente int 4
@fecha_proceso date 3
@cuit varchar 20
@procesar_todo varchar 1

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
select * from clientes where cliente in (select distinct cliente from pedidos_enriquecimiento)
exec pe_obtener_cuits '2144275673', '2019-04-12', '', 'T'
exec pe_obtener_cuits '$cliente', '$fecha', '$cuit', '$
todo'
*/

CREATE OR ALTER PROCEDURE dbo.pe_obtener_cuits
@cliente integer = null, 
@fecha_proceso date = null, 
@cuit varchar(20) = null,
@procesar_todo varchar(1) = 'N' -- T=todos N=No procesados

AS


BEGIN
    SET NOCOUNT ON;
 if (@cuit = '') set @cuit=null
 if (@cliente = '') set @cliente=null
 if (@fecha_proceso = '') set @fecha_proceso=null


  /*
   select distinct pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
   inner join padrones on identificacion = cuit and habilitado = 1
   --inner join RENAPER_INFO on RENAPER_INFO.identificacion = pedidos_enriquecimiento.cuit
   --where RENAPER_INFO.nacionalidad is not null  and pedidos_enriquecimiento.nacionalidad is null
   where isnull(nombre_todos,'') = ''
   */


 if (@cuit is not null and @cliente is not null and @fecha_proceso is not null) 
  select distinct cliente, fecha_proceso, pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
  inner join padrones on identificacion = cuit and habilitado = 1
  where cuit = @cuit
    and cliente = @cliente 
    and fecha_proceso = @fecha_proceso
    
if (@cuit is null) 
begin
 if (@cliente is null and @fecha_proceso is null) 
  select distinct cliente, fecha_proceso, pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
  inner join padrones on identificacion = cuit and habilitado = 1
  where (isnull(procesado,0) = 0 or @procesar_todo = 'T')
 
 if (@cliente is not null and @fecha_proceso is null) 
  select distinct cliente, fecha_proceso, pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
  inner join padrones on identificacion = cuit and habilitado = 1
  where cliente = @cliente 
    and (isnull(procesado,0) = 0 or @procesar_todo = 'T')

 if (@cliente is null and @fecha_proceso is not null) 
  select distinct cliente, fecha_proceso, pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
  inner join padrones on identificacion = cuit and habilitado = 1
  where fecha_proceso = @fecha_proceso
    and (isnull(procesado,0) = 0 or @procesar_todo = 'T')
 
 if (@cliente is not null and @fecha_proceso is not null) 
  select  distinct cliente, fecha_proceso, pedidos_enriquecimiento.cuit from pedidos_enriquecimiento 
  inner join padrones on identificacion = cuit and habilitado = 1
  where cliente = @cliente 
    and fecha_proceso = @fecha_proceso
    and (isnull(procesado,0) = 0 or @procesar_todo = 'T')
    --and isnull(domicilio_principal,'') = ''
end 
END

GO

Used By

No items found