Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @periodo | int | 4 | |
| @tipodoc | int | 4 | |
| @LedSeccion | varchar | 2 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_Duplicados_Select
@periodo int,
@tipodoc int,
@LedSeccion varchar(2)
AS
BEGIN
SET NOCOUNT ON;
select
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0) as empleado,isnull(t.vehiculo,0) as vehiculo,t.cliente
from
led_docs t
where t.periodo = @periodo and t.estado_doc in ('V') and t.led_seccion=@LedSeccion and t.tipo_doc = @tipodoc
/*
and t.cliente = 5546348 and t.tipo_doc=367 and t.contratista=53
*/
group by
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0),isnull(t.vehiculo,0),t.cliente
having
count(*) > 1
order by t.tipo_doc,t.led_seccion,t.contratista,empleado,vehiculo,t.cliente
/*
select
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0) as empleado,isnull(t.vehiculo,0) as vehiculo,t.cliente
from
led_docs t
where t.periodo = 201702 and t.estado_doc in ('V') and t.led_seccion='E'
/*
and t.cliente = 5546348 and t.tipo_doc=367 and t.contratista=53
*/
group by
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0),isnull(t.vehiculo,0),t.cliente
having
count(*) > 1
order by t.tipo_doc,t.led_seccion,t.contratista,empleado,vehiculo,t.cliente
/*
exec Imperium_Duplicados_Select 201702,737,'E'
update led_docs set estado_doc = 'J',compliance_doc='J',last_modified=getdate() where doc_id IN (4585645351)
update led_docs set estado_doc = 'J',compliance_doc='J',last_modified=getdate() where doc_id IN (
select min(doc_id) as doc_id from led_docs where periodo = 201702 and tipo_doc = 754 and empleado = 58873 and (replicated_doc_id is null or ingresado is null or vehiculo is null or verificado is null) and estado_doc in ('V')
)
select * from led_docs where periodo = 201702 and tipo_doc = 754 and empleado = 58873 and (replicated_doc_id is null or ingresado is null) and estado_doc in ('V')
select min(doc_id) as doc_id from led_docs where periodo = 201702 and tipo_doc = 346 and empleado = 48634 and replicated_doc_id is null and estado_doc in ('V')
*/
*/
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.Imperium_Duplicados_Select
@periodo int,
@tipodoc int,
@LedSeccion varchar(2)
AS
BEGIN
SET NOCOUNT ON;
select
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0) as empleado,isnull(t.vehiculo,0) as vehiculo,t.cliente
from
led_docs t
where t.periodo = @periodo and t.estado_doc in ('V') and t.led_seccion=@LedSeccion and t.tipo_doc = @tipodoc
/*
and t.cliente = 5546348 and t.tipo_doc=367 and t.contratista=53
*/
group by
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0),isnull(t.vehiculo,0),t.cliente
having
count(*) > 1
order by t.tipo_doc,t.led_seccion,t.contratista,empleado,vehiculo,t.cliente
/*
select
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0) as empleado,isnull(t.vehiculo,0) as vehiculo,t.cliente
from
led_docs t
where t.periodo = 201702 and t.estado_doc in ('V') and t.led_seccion='E'
/*
and t.cliente = 5546348 and t.tipo_doc=367 and t.contratista=53
*/
group by
t.tipo_doc, t.periodo, t.led_seccion,t.contratista,isnull(t.empleado,0),isnull(t.vehiculo,0),t.cliente
having
count(*) > 1
order by t.tipo_doc,t.led_seccion,t.contratista,empleado,vehiculo,t.cliente
/*
exec Imperium_Duplicados_Select 201702,737,'E'
update led_docs set estado_doc = 'J',compliance_doc='J',last_modified=getdate() where doc_id IN (4585645351)
update led_docs set estado_doc = 'J',compliance_doc='J',last_modified=getdate() where doc_id IN (
select min(doc_id) as doc_id from led_docs where periodo = 201702 and tipo_doc = 754 and empleado = 58873 and (replicated_doc_id is null or ingresado is null or vehiculo is null or verificado is null) and estado_doc in ('V')
)
select * from led_docs where periodo = 201702 and tipo_doc = 754 and empleado = 58873 and (replicated_doc_id is null or ingresado is null) and estado_doc in ('V')
select min(doc_id) as doc_id from led_docs where periodo = 201702 and tipo_doc = 346 and empleado = 48634 and replicated_doc_id is null and estado_doc in ('V')
*/
*/
END
GO
Depends On
1Used By
No items found