dbo.backend_obtener_integrantes_no_asignados_filtro_por_letra

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

1
Name Data Type Length Description
@p_letra varchar 1

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Samuel Gonzalez>
-- Create date: <13 Sep 2017>
-- Description: <Obtener integrantes no asignados en Sociedades Constituciones donde la sociedad ya está asignada para procesar por ABM>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.backend_obtener_integrantes_no_asignados_filtro_por_letra 
@p_letra varchar(1)
 -- Add the parameters for the stored procedure here

AS
BEGIN
 SET NOCOUNT ON;
    /*
        SELECT TOP 200
            sc.razon_social           as soc_nombre,
            sc.domicilio_sociedad     as soc_domicilio,
            sc.localidad_sociedad     as soc_localidad,
            sc.provincia_sociedad     as soc_provincia,
            sc.capita_social          as soc_capital_social,
            sc.titulo                 as pub_titulo,
            CAST(sc.objeto AS VARCHAR(MAX))as pub_objeto,
            sc.fuente                 as pub_fuente,
            sc.tipo_publicacion       as pub_tipo_1,
            sc.tipo_publicacion_2     as pub_tipo_2,
            sc.codigo_archivo         as pub_codigo,
            sc.nombre_file            as pub_archivo,
         sc.fecha_publicacion      as pub_fecha,
            sc.duracion               as pub_duracion,
            CAST(sc.contenido_archivo AS VARCHAR(MAX)) as pub_contenido,
            0 as es_sociedad,
            null as procesado
        FROM sociedades_constituciones sc
        INNER JOIN asignacion_cuits_sociedades_constituciones_log a
        ON (sc.id_fide = a.id_sociedades_constituciones) AND (a.es_sociedad = 0) AND (a.procesado_2 IS NULL)
        INNER JOIN (
            select scx.razon_social, scx.nombre_file, scx.codigo_archivo from sociedades_constituciones scx 
            inner join asignacion_cuits_sociedades_constituciones_log ax on (scx.id_fide = ax.id_sociedades_constituciones)
            where (es_sociedad = 1) and (procesado_2 = 1)
        ) zz ON (sc.razon_social = zz.razon_social) AND (sc.nombre_file = zz.nombre_file) AND (sc.codigo_archivo = zz.codigo_archivo)
        WHERE (sc.flag_int = 'B') 
        AND (sc.cuit_int IS NULL or sc.cuit_int = '')
        AND (sc.razon_social like @p_letra +'%')
        -- EN TEORIA, SOCIEDADES ENCONTRADAS, QUE POSEEN INTEGRANTES NO ENCONTRADOS POR MULTIPLICIDAD
    
        UNION
    
        SELECT TOP 200
            sc.razon_social           as soc_nombre,
            sc.domicilio_sociedad     as soc_domicilio,
            sc.localidad_sociedad     as soc_localidad,
            sc.provincia_sociedad     as soc_provincia,
            sc.capita_social          as soc_capital_social,
            sc.titulo                 as pub_titulo,
            CAST(sc.objeto AS VARCHAR(MAX))as pub_objeto,
            sc.fuente                 as pub_fuente,
            sc.tipo_publicacion       as pub_tipo_1,
            sc.tipo_publicacion_2     as pub_tipo_2,
            sc.codigo_archivo         as pub_codigo,
            sc.nombre_file            as pub_archivo,
         sc.fecha_publicacion      as pub_fecha,
            sc.duracion               as pub_duracion,
            CAST(sc.contenido_archivo AS VARCHAR(MAX)) as pub_contenido,
            0 as es_sociedad,
            null as procesado
        FROM sociedades_constituciones sc
        INNER JOIN asignacion_cuits_sociedades_constituciones_log a
        ON (sc.id_fide = a.id_sociedades_constituciones) AND (a.es_sociedad = 0) AND (a.procesado_2 = 0)
        INNER JOIN (
            select scx.razon_social, scx.nombre_file, scx.codigo_archivo from sociedades_constituciones scx 
            inner join asignacion_cuits_sociedades_constituciones_log ax on (scx.id_fide = ax.id_sociedades_constituciones)
            where (es_sociedad = 1) and (procesado_2 = 1)
        ) zz ON (sc.razon_social = zz.razon_social) AND (sc.nombre_file = zz.nombre_file) AND (sc.codigo_archivo = zz.codigo_archivo)
        WHERE (sc.flag_int = 'B') 
        AND (sc.cuit_int IS NULL or sc.cuit_int = '')
        AND (sc.razon_social like @p_letra +'%')
        -- EN TEORIA, SOCIEDADES ENCONTRADAS, QUE POSEEN INTEGRANTES NO ENCONTRADOS POR MULTIPLICIDAD
        */



    SELECT TOP 200
        sc.razon_social           as soc_nombre,
        sc.documento_soc          as soc_cuit,
        sc.domicilio_sociedad     as soc_domicilio,
        sc.localidad_sociedad     as soc_localidad,
        sc.provincia_sociedad     as soc_provincia,
        sc.capita_social          as soc_capital_social,
        sc.titulo                 as pub_titulo,
        CAST(sc.objeto AS VARCHAR)as pub_objeto,
        sc.fuente                 as pub_fuente,
        sc.tipo_publicacion       as pub_tipo_1,
        sc.tipo_publicacion_2     as pub_tipo_2,
        sc.codigo_archivo         as pub_codigo,
        sc.nombre_file            as pub_archivo,
     sc.fecha_publicacion      as pub_fecha,
        sc.duracion               as pub_duracion,
        CAST(sc.contenido_archivo AS VARCHAR(MAX)) as pub_contenido,
        0 as es_sociedad,
        null as procesado
    FROM sociedades_constituciones sc
    INNER JOIN (
        select scx.razon_social, scx.nombre_file, scx.codigo_archivo from sociedades_constituciones scx 
        inner join asignacion_cuits_sociedades_constituciones_log ax on (scx.id_fide = ax.id_sociedades_constituciones)
        where (es_sociedad = 1) and (procesado_2 = 1)
    ) zz ON (sc.razon_social = zz.razon_social) AND (sc.nombre_file = zz.nombre_file) AND (sc.codigo_archivo = zz.codigo_archivo)
    WHERE -- (sc.flag_int = 'B') AND 
    (sc.cuit_int IS NULL or sc.cuit_int = '') AND (nombre_integrante != '') AND (nombre_integrante IS NOT NULL) AND (sc.nombre_integrante != sc.razon_social) AND (sc.razon_social like @p_letra +'%')
    -- EN TEORIA, SOCIEDADES ENCONTRADAS, QUE POSEEN INTEGRANTES NO ENCONTRADOS


    ORDER BY fecha_publicacion

END

GO