Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
1| Name | Data Type | Length | Description |
|---|---|---|---|
| @cuit | varchar | 20 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
create OR ALTER PROCEDURE dbo.sp_buscar_parientes
@cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
select distinct
cuilti as cuit, b.nombre_persona as sociedad,
NRODOC as cuit_integrante, APEYNO as nombre_integrante, 'PARIENTE' as cargo
from obras_sociales_beneficiarios os
inner join padrones b on b.identificacion = cuilti and b.habilitado = 1
where os.cuilti = @cuit
union
select distinct
NRODOC as cuit, a.nombre_persona as sociedad,
cuilti as cuit_integrante, b.nombre_persona as nombre_integrante, 'PARIENTE' as cargo
from obras_sociales_beneficiarios os
inner join padrones a on a.identificacion = NRODOC and a.habilitado = 1
inner join padrones b on b.identificacion = cuilti and b.habilitado = 1
where os.nrodoc = @cuit
union
select distinct
cuil_Activo as cuit, b.nombre_persona as sociedad,
cuilrelacionado as cuit_integrante, a.nombre_persona as nombre_integrante,
case ltrim(rtrim(descrelacion))
when null then 'PARIENTE'
when '' then 'PARIENTE'
else ltrim(rtrim(descrelacion))
end as cargo
from obrasSociales os
inner join padrones a on a.identificacion = cuilrelacionado and a.habilitado = 1
inner join padrones b on b.identificacion = cuil_Activo and b.habilitado = 1
where os.cuil_Activo = @cuit
union
select distinct
cuilrelacionado as cuit, b.nombre_persona as sociedad,
cuil_Activo as cuit_integrante, a.nombre_persona as nombre_integrante,
case ltrim(rtrim(descrelacion))
when null then 'PARIENTE'
when '' then 'PARIENTE'
else ltrim(rtrim(descrelacion))
end as cargo
from obrasSociales os
inner join padrones a on a.identificacion = cuilrelacionado and a.habilitado = 1
inner join padrones b on b.identificacion = cuil_Activo and b.habilitado = 1
where os.cuilrelacionado = @cuit
end
GO
GO
create OR ALTER PROCEDURE dbo.sp_buscar_parientes
@cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
select distinct
cuilti as cuit, b.nombre_persona as sociedad,
NRODOC as cuit_integrante, APEYNO as nombre_integrante, 'PARIENTE' as cargo
from obras_sociales_beneficiarios os
inner join padrones b on b.identificacion = cuilti and b.habilitado = 1
where os.cuilti = @cuit
union
select distinct
NRODOC as cuit, a.nombre_persona as sociedad,
cuilti as cuit_integrante, b.nombre_persona as nombre_integrante, 'PARIENTE' as cargo
from obras_sociales_beneficiarios os
inner join padrones a on a.identificacion = NRODOC and a.habilitado = 1
inner join padrones b on b.identificacion = cuilti and b.habilitado = 1
where os.nrodoc = @cuit
union
select distinct
cuil_Activo as cuit, b.nombre_persona as sociedad,
cuilrelacionado as cuit_integrante, a.nombre_persona as nombre_integrante,
case ltrim(rtrim(descrelacion))
when null then 'PARIENTE'
when '' then 'PARIENTE'
else ltrim(rtrim(descrelacion))
end as cargo
from obrasSociales os
inner join padrones a on a.identificacion = cuilrelacionado and a.habilitado = 1
inner join padrones b on b.identificacion = cuil_Activo and b.habilitado = 1
where os.cuil_Activo = @cuit
union
select distinct
cuilrelacionado as cuit, b.nombre_persona as sociedad,
cuil_Activo as cuit_integrante, a.nombre_persona as nombre_integrante,
case ltrim(rtrim(descrelacion))
when null then 'PARIENTE'
when '' then 'PARIENTE'
else ltrim(rtrim(descrelacion))
end as cargo
from obrasSociales os
inner join padrones a on a.identificacion = cuilrelacionado and a.habilitado = 1
inner join padrones b on b.identificacion = cuil_Activo and b.habilitado = 1
where os.cuilrelacionado = @cuit
end
GO
Used By
No items found