Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_Racalcula_Compliance_Select
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER SMALLINT
/*
@Cliente INT,
@Per INT
select distinct contratista, periodo,led_seccion from led_DOCS
where last_modified > getdate()-10
where cliente = @Cliente and periodo = @Per
select getdate(),getdate()-0.014 ULTIMOS 20 MINUTOS
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and periodo in (201701,201702)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and periodo in (201701,201702)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and periodo in (201701,201702)
order by contratista desc
or contratista in (select distinct contratista from led_contratistas where cliente in (select cliente from clientes where ACCESO_LED = 1 and cliente <> 5546348)))
select getdate()-0.05
*/
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C'
and (last_modified > getdate()- 0.05) /* and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05)
/*
and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05)/* and cliente not in (9335603)*/
order by periodo desc
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1,null as empleado,null as vehiculo from led_DOCS
WHERE led_seccion = 'C'
and (last_modified > getdate()-0.05) /* and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1,empleado,null as vehiculo from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05 )
/*
and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1,null as empleado,vehiculo from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05 )/* and cliente not in (9335603)*/
order by periodo desc
*/
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and (last_modified > getdate()-0.05)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05 )
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05 )
order by periodo desc
*/
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and (periodo in (201612,201611,201701,201702,201703))
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (periodo in (201612,201611,201701,201702,201703))
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (periodo in (201612,201611,201701,201702,201703))
order by periodo desc
*/
/*
select distinct LC.contratista, lcp.periodo,'C' as led_seccion,LC.contratista_1
from led_contratista_periodo LCP inner join led_contratistas LC on LCP.contratista = LC.contratista
WHERE lcp.periodo in (201701,201702) and lc.estado_contratista = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LCP.subcontratista as contratista, LCP.periodo, 'S' as led_seccion,LCP.contratista_1
from led_subcontratista_periodo LCP inner join led_contratistas LC on LCP.subcontratista = LC.contratista
WHERE lcp.periodo in (201701,201702) and LC.estado_contratista = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LC.contratista, lcp.periodo,'E' as led_seccion,LC.contratista_1
from led_empleados_periodo LCP inner join led_empleados LC on LCP.empleado = LC.empleado
WHERE lcp.periodo in (201701,201702) and lc.estado_empleado = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LC.contratista, lcp.periodo,'V' as led_seccion,LC.contratista_1
from led_vehiculos_periodo LCP inner join led_vehiculos LC on LCP.vehiculo = LC.vehiculo
WHERE lcp.periodo in (201701,201702) and lc.estado_vehiculo = 'A' and lc.contratista > 1086
and lc.contratista > 0
order by contratista asc,periodo desc
select distinct contratista,periodo,led_seccion from led_docs where estado_doc = 'I' and cliente = 9936068
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and estado_doc = 'I' and cliente = 1875643264
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and estado_doc = 'I' and cliente = 1875643264
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and estado_doc = 'I' and cliente = 1875643264
order by periodo desc
*/
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_Racalcula_Compliance_Select
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ERRORNUMBER SMALLINT
/*
@Cliente INT,
@Per INT
select distinct contratista, periodo,led_seccion from led_DOCS
where last_modified > getdate()-10
where cliente = @Cliente and periodo = @Per
select getdate(),getdate()-0.014 ULTIMOS 20 MINUTOS
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and periodo in (201701,201702)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and periodo in (201701,201702)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and periodo in (201701,201702)
order by contratista desc
or contratista in (select distinct contratista from led_contratistas where cliente in (select cliente from clientes where ACCESO_LED = 1 and cliente <> 5546348)))
select getdate()-0.05
*/
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C'
and (last_modified > getdate()- 0.05) /* and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05)
/*
and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05)/* and cliente not in (9335603)*/
order by periodo desc
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1,null as empleado,null as vehiculo from led_DOCS
WHERE led_seccion = 'C'
and (last_modified > getdate()-0.05) /* and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1,empleado,null as vehiculo from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05 )
/*
and cliente not in (9335603)*/
union all
select distinct contratista, periodo,led_seccion,contratista_1,null as empleado,vehiculo from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05 )/* and cliente not in (9335603)*/
order by periodo desc
*/
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and (last_modified > getdate()-0.05)
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (last_modified > getdate()-0.05 )
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (last_modified > getdate()-0.05 )
order by periodo desc
*/
/*
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and (periodo in (201612,201611,201701,201702,201703))
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and (periodo in (201612,201611,201701,201702,201703))
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and (periodo in (201612,201611,201701,201702,201703))
order by periodo desc
*/
/*
select distinct LC.contratista, lcp.periodo,'C' as led_seccion,LC.contratista_1
from led_contratista_periodo LCP inner join led_contratistas LC on LCP.contratista = LC.contratista
WHERE lcp.periodo in (201701,201702) and lc.estado_contratista = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LCP.subcontratista as contratista, LCP.periodo, 'S' as led_seccion,LCP.contratista_1
from led_subcontratista_periodo LCP inner join led_contratistas LC on LCP.subcontratista = LC.contratista
WHERE lcp.periodo in (201701,201702) and LC.estado_contratista = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LC.contratista, lcp.periodo,'E' as led_seccion,LC.contratista_1
from led_empleados_periodo LCP inner join led_empleados LC on LCP.empleado = LC.empleado
WHERE lcp.periodo in (201701,201702) and lc.estado_empleado = 'A' and lc.contratista > 1086
and lc.contratista > 0
union all
select distinct LC.contratista, lcp.periodo,'V' as led_seccion,LC.contratista_1
from led_vehiculos_periodo LCP inner join led_vehiculos LC on LCP.vehiculo = LC.vehiculo
WHERE lcp.periodo in (201701,201702) and lc.estado_vehiculo = 'A' and lc.contratista > 1086
and lc.contratista > 0
order by contratista asc,periodo desc
select distinct contratista,periodo,led_seccion from led_docs where estado_doc = 'I' and cliente = 9936068
select distinct contratista, periodo,iif(contratista = contratista_1,'C','S') as led_seccion,contratista_1 from led_DOCS
WHERE led_seccion = 'C' and estado_doc = 'I' and cliente = 1875643264
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'E' and estado_doc = 'I' and cliente = 1875643264
union all
select distinct contratista, periodo,led_seccion,contratista_1 from led_DOCS
where led_seccion = 'V' and estado_doc = 'I' and cliente = 1875643264
order by periodo desc
*/
END
GO
Depends On
1Used By
No items found