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
--[backend_empleados_periodo2] '30641368977'
CREATE OR ALTER PROCEDURE dbo.backend_empleados_periodo2
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
/*
select distinct periodo,
right('00'+(cast(datepart(MM,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar)),2)+'/'+cast(DATEPART(YY,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar) as periodo_mmyy
from empleados
where (cuit = @p_Cuit
and visible = '1')
order by periodo desc
*/
declare @per int
declare @per_my varchar(7)
declare @total decimal(16,2)
declare @resultado table (periodo int, periodo_mmyy varchar(7), total decimal(16,2))
begin
DECLARE recorre CURSOR
FOR
select distinct periodo,
right('00'+(cast(datepart(MM,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar)),2)+'/'+cast(DATEPART(YY,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar) as periodo_mmyy
from empleados
where (cuit = @p_Cuit
and visible = '1')
order by periodo desc
OPEN recorre
Fetch next from recorre INTO @per, @per_my
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
select @total = isnull(sum(subquery.sueldo),0)
from ( select distinct empleados.cuil, 0 as sueldo
from empleados
where cuit = @p_Cuit
and visible = '1'
and periodo = @per) subquery
insert into @resultado values (@per,@per_my,@total)
Fetch next from recorre INTO @per, @per_my
END
CLOSE recorre
DEALLOCATE recorre
select * from @resultado
end
END
GO
GO
--[backend_empleados_periodo2] '30641368977'
CREATE OR ALTER PROCEDURE dbo.backend_empleados_periodo2
@p_Cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
/*
select distinct periodo,
right('00'+(cast(datepart(MM,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar)),2)+'/'+cast(DATEPART(YY,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar) as periodo_mmyy
from empleados
where (cuit = @p_Cuit
and visible = '1')
order by periodo desc
*/
declare @per int
declare @per_my varchar(7)
declare @total decimal(16,2)
declare @resultado table (periodo int, periodo_mmyy varchar(7), total decimal(16,2))
begin
DECLARE recorre CURSOR
FOR
select distinct periodo,
right('00'+(cast(datepart(MM,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar)),2)+'/'+cast(DATEPART(YY,cast('20'+cast(periodo as char(4))+'01' as date)) as varchar) as periodo_mmyy
from empleados
where (cuit = @p_Cuit
and visible = '1')
order by periodo desc
OPEN recorre
Fetch next from recorre INTO @per, @per_my
WHILE (@@FETCH_STATUS <> -1 )
BEGIN
select @total = isnull(sum(subquery.sueldo),0)
from ( select distinct empleados.cuil, 0 as sueldo
from empleados
where cuit = @p_Cuit
and visible = '1'
and periodo = @per) subquery
insert into @resultado values (@per,@per_my,@total)
Fetch next from recorre INTO @per, @per_my
END
CLOSE recorre
DEALLOCATE recorre
select * from @resultado
end
END
GO
Depends On
1Used By
No items found