Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @cliente | int | 4 | |
| @desde | date | 3 | |
| @hasta | date | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec user_client_actions_ 1562620024
exec user_client_actions_ 2254875
*/
CREATE OR ALTER PROCEDURE dbo.user_client_actions_
-- PARAMETROS
@cliente int = 1562620024,
@desde date = null,
@hasta date = null
AS
BEGIN
-- De una contraparte
if @desde is null set @desde = '2000-01-01'
if @hasta is null set @hasta = CONVERT(date,GETDATE())
select users.username, user_client_actions.created,
convert(varchar,user_client_actions.created,103) + ' ' + convert(varchar,user_client_actions.created,108) as fecha,
padrones.identificador, padrones.identificacion as TAXID,padrones.nombre_persona,
user_client_actions.route,
IIF (action_route_text.text is null, user_client_actions.route,action_route_text.text) + iif (clave_indicador is not null, ' - Filtro ' + clave_indicador, '') + iif (filtro is not null, ' ' + filtro, '') as ruta,
user_client_actions.ip
--,user_client_actions.clave_indicador,user_client_actions.filtro
from user_client_actions
left join action_route_text on action_route_text.route = user_client_actions.route
inner join ln_contrapartes on ln_contrapartes.contraparte = user_client_actions.contrapartes
inner join padrones on ln_contrapartes.id_padron=padrones.id_padron
inner join users on user_client_actions.user_id=users.user_id
where user_client_actions.client_id=@cliente
and user_client_actions.user_id!=434439085
and user_client_actions.contrapartes is not null and user_client_actions.contrapartes not like '%,%'
and CONVERT(date,user_client_actions.created) between @desde and @hasta
UNION
-- No es de una contraparte, puede ser de una lista o de un tax-id
select users.username, user_client_actions.created,
convert(varchar,user_client_actions.created,103) + ' ' + convert(varchar,user_client_actions.created,108) as fecha,
padrones.identificador, padrones.identificacion as TAXID,padrones.nombre_persona,
user_client_actions.route,
IIF (action_route_text.text is null, user_client_actions.route,action_route_text.text) + iif (clave_indicador is not null, ' - Filtro ' + clave_indicador, '') + iif (filtro is not null, ' ' + filtro, '') as ruta,
user_client_actions.ip
--,user_client_actions.clave_indicador,user_client_actions.filtro
from user_client_actions
left join action_route_text on action_route_text.route = user_client_actions.route
left join padrones on user_client_actions.identificacion=padrones.identificacion
inner join users on user_client_actions.user_id=users.user_id
where user_client_actions.client_id=@cliente
and user_client_actions.user_id!=434439085
and (user_client_actions.contrapartes is null or user_client_actions.contrapartes like '%,%')
and CONVERT(date,user_client_actions.created) between @desde and @hasta
order by user_client_actions.created asc
END
GO
GO
/*
exec user_client_actions_ 1562620024
exec user_client_actions_ 2254875
*/
CREATE OR ALTER PROCEDURE dbo.user_client_actions_
-- PARAMETROS
@cliente int = 1562620024,
@desde date = null,
@hasta date = null
AS
BEGIN
-- De una contraparte
if @desde is null set @desde = '2000-01-01'
if @hasta is null set @hasta = CONVERT(date,GETDATE())
select users.username, user_client_actions.created,
convert(varchar,user_client_actions.created,103) + ' ' + convert(varchar,user_client_actions.created,108) as fecha,
padrones.identificador, padrones.identificacion as TAXID,padrones.nombre_persona,
user_client_actions.route,
IIF (action_route_text.text is null, user_client_actions.route,action_route_text.text) + iif (clave_indicador is not null, ' - Filtro ' + clave_indicador, '') + iif (filtro is not null, ' ' + filtro, '') as ruta,
user_client_actions.ip
--,user_client_actions.clave_indicador,user_client_actions.filtro
from user_client_actions
left join action_route_text on action_route_text.route = user_client_actions.route
inner join ln_contrapartes on ln_contrapartes.contraparte = user_client_actions.contrapartes
inner join padrones on ln_contrapartes.id_padron=padrones.id_padron
inner join users on user_client_actions.user_id=users.user_id
where user_client_actions.client_id=@cliente
and user_client_actions.user_id!=434439085
and user_client_actions.contrapartes is not null and user_client_actions.contrapartes not like '%,%'
and CONVERT(date,user_client_actions.created) between @desde and @hasta
UNION
-- No es de una contraparte, puede ser de una lista o de un tax-id
select users.username, user_client_actions.created,
convert(varchar,user_client_actions.created,103) + ' ' + convert(varchar,user_client_actions.created,108) as fecha,
padrones.identificador, padrones.identificacion as TAXID,padrones.nombre_persona,
user_client_actions.route,
IIF (action_route_text.text is null, user_client_actions.route,action_route_text.text) + iif (clave_indicador is not null, ' - Filtro ' + clave_indicador, '') + iif (filtro is not null, ' ' + filtro, '') as ruta,
user_client_actions.ip
--,user_client_actions.clave_indicador,user_client_actions.filtro
from user_client_actions
left join action_route_text on action_route_text.route = user_client_actions.route
left join padrones on user_client_actions.identificacion=padrones.identificacion
inner join users on user_client_actions.user_id=users.user_id
where user_client_actions.client_id=@cliente
and user_client_actions.user_id!=434439085
and (user_client_actions.contrapartes is null or user_client_actions.contrapartes like '%,%')
and CONVERT(date,user_client_actions.created) between @desde and @hasta
order by user_client_actions.created asc
END
GO
Depends On
3Used By
No items found