Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
1| Name | Data Type | Length | Description |
|---|---|---|---|
| @periodo | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
*/
CREATE OR ALTER PROCEDURE dbo.nominas_rango
@periodo int
AS
BEGIN
SET NOCOUNT ON;
declare @cuit varchar(20)
declare @nomina decimal(15,2)
DECLARE C_Nominas CURSOR FOR
select distinct cuit from empleados where periodo in (@periodo)
OPEN C_Nominas
FETCH NEXT FROM C_Nominas INTO @cuit
WHILE @@fetch_status = 0
BEGIN
select @nomina = isnull(sum(distinct remimp),0) from empleados a
where cuit = @cuit
and visible = '1'
and periodo = @periodo
and not exists (select * from empleados c
where c.cuit = a.cuit
and c.cuil = a.cuil
and c.periodo = a.periodo
and c.created > a.created)
insert into rango_nominas (cuit,periodo,rango_nomina)
values (@cuit,@periodo,@nomina)
FETCH NEXT FROM C_Nominas INTO @cuit
END
CLOSE C_Nominas
DEALLOCATE C_Nominas
END
GO
GO
/*
*/
CREATE OR ALTER PROCEDURE dbo.nominas_rango
@periodo int
AS
BEGIN
SET NOCOUNT ON;
declare @cuit varchar(20)
declare @nomina decimal(15,2)
DECLARE C_Nominas CURSOR FOR
select distinct cuit from empleados where periodo in (@periodo)
OPEN C_Nominas
FETCH NEXT FROM C_Nominas INTO @cuit
WHILE @@fetch_status = 0
BEGIN
select @nomina = isnull(sum(distinct remimp),0) from empleados a
where cuit = @cuit
and visible = '1'
and periodo = @periodo
and not exists (select * from empleados c
where c.cuit = a.cuit
and c.cuil = a.cuil
and c.periodo = a.periodo
and c.created > a.created)
insert into rango_nominas (cuit,periodo,rango_nomina)
values (@cuit,@periodo,@nomina)
FETCH NEXT FROM C_Nominas INTO @cuit
END
CLOSE C_Nominas
DEALLOCATE C_Nominas
END
GO
Depends On
1Used By
No items found