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_bancos_DEV
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @periodo_maximo varchar(10),@periodo_minimo date,@db_periodo_maximo int,@db_periodo_minimo int
select @periodo_maximo = max(cendeu.fec_inf) from cendeu where iden = @p_Cuit
if @periodo_maximo is not null
begin
set @periodo_maximo = @periodo_maximo+'01'
set @periodo_minimo = dateadd(MONTH,-24,convert(date,@periodo_maximo))
set @db_periodo_minimo = convert(int,format(@periodo_minimo,'yyyy')+format(@periodo_minimo,'MM'))
set @db_periodo_maximo = convert(int,format(convert(date,@periodo_maximo),'yyyy')+format(convert(date,@periodo_maximo),'MM'))
select distinct
nombre,
cendeu.codigo_ent,
(select((prestamos+particip+garotor+o_cptos)*1000) as total from cendeu right join EntidadesBancarias on cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit and fec_inf = @db_periodo_minimo and cendeu.vigente = 1) as total,
(select sum(garotor) as pepe from cendeu right join EntidadesBancarias on cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit and fec_inf = 201509 and cendeu.vigente = 1) as 'pepe'
from cendeu inner join EntidadesBancarias on
cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit
AND fec_inf between @db_periodo_minimo and @db_periodo_maximo and cendeu.vigente = 1
end
else
begin
select '0' as resultado
end
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.obtener_bancos_DEV
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @periodo_maximo varchar(10),@periodo_minimo date,@db_periodo_maximo int,@db_periodo_minimo int
select @periodo_maximo = max(cendeu.fec_inf) from cendeu where iden = @p_Cuit
if @periodo_maximo is not null
begin
set @periodo_maximo = @periodo_maximo+'01'
set @periodo_minimo = dateadd(MONTH,-24,convert(date,@periodo_maximo))
set @db_periodo_minimo = convert(int,format(@periodo_minimo,'yyyy')+format(@periodo_minimo,'MM'))
set @db_periodo_maximo = convert(int,format(convert(date,@periodo_maximo),'yyyy')+format(convert(date,@periodo_maximo),'MM'))
select distinct
nombre,
cendeu.codigo_ent,
(select((prestamos+particip+garotor+o_cptos)*1000) as total from cendeu right join EntidadesBancarias on cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit and fec_inf = @db_periodo_minimo and cendeu.vigente = 1) as total,
(select sum(garotor) as pepe from cendeu right join EntidadesBancarias on cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit and fec_inf = 201509 and cendeu.vigente = 1) as 'pepe'
from cendeu inner join EntidadesBancarias on
cendeu.codigo_ent = EntidadesBancarias.id_banco
where iden = @p_Cuit
AND fec_inf between @db_periodo_minimo and @db_periodo_maximo and cendeu.vigente = 1
end
else
begin
select '0' as resultado
end
END
GO
Depends On
2Used By
No items found