Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
2| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_cliente | int | 4 | |
| @servicio_contratado | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.LN_contrapartes_por_ejecutivo
@p_cliente int = 861672084, -- Arcor
@servicio_contratado int = 47
AS
BEGIN
SET NOCOUNT ON;
SELECT distinct SUBSTRING(email_ejecutivo_cuenta,1,CHARINDEX('@', email_ejecutivo_cuenta)-1) AS nombre, email_ejecutivo_cuenta,
STUFF((
SELECT ',' + convert(varchar,LN_contrapartes.contraparte)
from LN_contrapartes
inner join LN_gestiones on LN_contrapartes.contraparte = LN_gestiones.contraparte
inner join LN_contraparte_familias on LN_contrapartes.contraparte = LN_contraparte_familias.contraparte
WHERE LN_contrapartes.cliente = @p_cliente
and LN_gestiones.desde <= getdate() and LN_gestiones.hasta >= getdate()
and ln_gestiones.vigente = 1
and LN_contraparte_familias.activo = 1
and LN_contrapartes.activo = 1
and isnull(ln_contrapartes.servicio_contratado,47)=@servicio_contratado
AND LN_contrapartes.subcontratista = 0
and LN_contrapartes.email_ejecutivo_cuenta = b.email_ejecutivo_cuenta
FOR XML PATH('')
), 1, 1, '') AS lista
from LN_contrapartes b
inner join LN_gestiones g on b.contraparte = g.contraparte
inner join LN_contraparte_familias f on b.contraparte = f.contraparte
WHERE b.cliente = @p_cliente
and g.desde <= getdate() and g.hasta >= getdate()
and g.vigente = 1
and f.activo = 1
and b.activo = 1
and isnull(b.servicio_contratado,47)=@servicio_contratado
AND b.subcontratista = 0
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.LN_contrapartes_por_ejecutivo
@p_cliente int = 861672084, -- Arcor
@servicio_contratado int = 47
AS
BEGIN
SET NOCOUNT ON;
SELECT distinct SUBSTRING(email_ejecutivo_cuenta,1,CHARINDEX('@', email_ejecutivo_cuenta)-1) AS nombre, email_ejecutivo_cuenta,
STUFF((
SELECT ',' + convert(varchar,LN_contrapartes.contraparte)
from LN_contrapartes
inner join LN_gestiones on LN_contrapartes.contraparte = LN_gestiones.contraparte
inner join LN_contraparte_familias on LN_contrapartes.contraparte = LN_contraparte_familias.contraparte
WHERE LN_contrapartes.cliente = @p_cliente
and LN_gestiones.desde <= getdate() and LN_gestiones.hasta >= getdate()
and ln_gestiones.vigente = 1
and LN_contraparte_familias.activo = 1
and LN_contrapartes.activo = 1
and isnull(ln_contrapartes.servicio_contratado,47)=@servicio_contratado
AND LN_contrapartes.subcontratista = 0
and LN_contrapartes.email_ejecutivo_cuenta = b.email_ejecutivo_cuenta
FOR XML PATH('')
), 1, 1, '') AS lista
from LN_contrapartes b
inner join LN_gestiones g on b.contraparte = g.contraparte
inner join LN_contraparte_familias f on b.contraparte = f.contraparte
WHERE b.cliente = @p_cliente
and g.desde <= getdate() and g.hasta >= getdate()
and g.vigente = 1
and f.activo = 1
and b.activo = 1
and isnull(b.servicio_contratado,47)=@servicio_contratado
AND b.subcontratista = 0
END
GO
Used By
No items found