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_Cuit | varchar | 20 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.obtener_garantias_brief
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @periodo_maximo date,@periodo_maximo_cuit date,@fecha_formateada varchar(10),@periodo_comparar varchar(6);
select @periodo_maximo = (select max(fecha_informacion) from fuentes_procesadas where visible = '1' and fuente ='cendeu')
select @periodo_maximo_cuit = convert(date,isnull(max(cendeu.fec_inf),'200112')+'01') from cendeu where iden = @p_cuit AND vigente = 1
if (@periodo_maximo_cuit > @periodo_maximo)
begin
set @periodo_maximo = @periodo_maximo_cuit
end
if @periodo_maximo is not null
begin
set @fecha_formateada = right('0' + rtrim(convert(varchar(6),(datepart(MM,@periodo_maximo)))),2) +'/'+convert(varchar(6),DATEPART(YY,@periodo_maximo))
set @periodo_comparar = convert(varchar(6),DATEPART(YY,@periodo_maximo))+ right('0' + rtrim(convert(varchar(6),(datepart(MM,@periodo_maximo)))),2)
select cast(sum(cgarprefa) as int) as cgarprefa,cast(sum(cgarprefb) as int ) as cgarprefb,
cast(sum(singarpref) as int) as singarpref,cast(sum(cgarprefa+cgarprefb+singarpref+deuda_total) as int) as total ,@fecha_formateada as ultimo_periodo FROM cendeu where iden=@p_Cuit and fec_inf = @periodo_comparar
end
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.obtener_garantias_brief
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @periodo_maximo date,@periodo_maximo_cuit date,@fecha_formateada varchar(10),@periodo_comparar varchar(6);
select @periodo_maximo = (select max(fecha_informacion) from fuentes_procesadas where visible = '1' and fuente ='cendeu')
select @periodo_maximo_cuit = convert(date,isnull(max(cendeu.fec_inf),'200112')+'01') from cendeu where iden = @p_cuit AND vigente = 1
if (@periodo_maximo_cuit > @periodo_maximo)
begin
set @periodo_maximo = @periodo_maximo_cuit
end
if @periodo_maximo is not null
begin
set @fecha_formateada = right('0' + rtrim(convert(varchar(6),(datepart(MM,@periodo_maximo)))),2) +'/'+convert(varchar(6),DATEPART(YY,@periodo_maximo))
set @periodo_comparar = convert(varchar(6),DATEPART(YY,@periodo_maximo))+ right('0' + rtrim(convert(varchar(6),(datepart(MM,@periodo_maximo)))),2)
select cast(sum(cgarprefa) as int) as cgarprefa,cast(sum(cgarprefb) as int ) as cgarprefb,
cast(sum(singarpref) as int) as singarpref,cast(sum(cgarprefa+cgarprefb+singarpref+deuda_total) as int) as total ,@fecha_formateada as ultimo_periodo FROM cendeu where iden=@p_Cuit and fec_inf = @periodo_comparar
end
END
GO
Depends On
2Used By
No items found