
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_equ_pagoAlquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_equ_pagoAlquiler]
GO
CREATE PROCEDURE [reg_equ_pagoAlquiler]
	@p_id INT
AS
BEGIN
	SELECT 	[id] AS [id],
		[uid] AS [uid],
		[eid] AS [eid],
		[id_usuario_modifico] AS [id_usuario_modifico],
		[id_usuario_creo] AS [id_usuario_creo],
		[fechaModificacion] AS [fechaModificacion],
		[fechaCreacion] AS [fechaCreacion],
		[active] AS [active],
		[pagoAlquiler] AS [pagoAlquiler],
		[pagoAlquiler_codigo] AS [pagoAlquiler_codigo],
		[valorPorCobrar] AS [valorPorCobrar],
		[valorFacturado] AS [valorFacturado],
		[numeroFactura] AS [numeroFactura],
		[fechaEsperadaPago_ff] AS [fechaEsperadaPago_ff],
		[fecha_factura_ff] AS [fecha_factura_ff],
		[id_documento.alquiler] AS [id_documento.alquiler]
	FROM [equ_pagoAlquiler]
	WHERE	(id = @p_id)

END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[view_equ_pagoAlquiler]')) DROP VIEW [dbo].[view_equ_pagoAlquiler]
GO
CREATE  VIEW [view_equ_pagoAlquiler] AS
SELECT 	[equ_pagoAlquiler].[id] AS [id],
		[equ_pagoAlquiler].[uid] AS [uid],
		[equ_pagoAlquiler].[eid] AS [eid],
		[equ_pagoAlquiler].[id_usuario_modifico] AS [id_usuario_modifico],
		[equ_pagoAlquiler].[id_usuario_creo] AS [id_usuario_creo],
		[equ_pagoAlquiler].[fechaModificacion] AS [fechaModificacion],
		[equ_pagoAlquiler].[fechaCreacion] AS [fechaCreacion],
		[equ_pagoAlquiler].[active] AS [active],
		[equ_pagoAlquiler].[pagoAlquiler] AS [pagoAlquiler],
		[equ_pagoAlquiler].[pagoAlquiler_codigo] AS [pagoAlquiler_codigo],
		[equ_pagoAlquiler].[valorPorCobrar] AS [valorPorCobrar],
		[equ_pagoAlquiler].[valorFacturado] AS [valorFacturado],
		[equ_pagoAlquiler].[numeroFactura] AS [numeroFactura],
		[equ_pagoAlquiler].[fechaEsperadaPago_ff] AS [fechaEsperadaPago_ff],
		[equ_pagoAlquiler].[fecha_factura_ff] AS [fecha_factura_ff],
		[equ_pagoAlquiler].[id_documento.alquiler] AS [id_documento.alquiler],
[doc_documento.alquiler].[documento.alquiler] as [doc_documento.alquiler_documento.alquiler],
[doc_documento.alquiler].[fechaFin_ff] as [doc_documento.alquiler_fechaFin_ff],
[doc_documento.alquiler].[mesVencido] as [doc_documento.alquiler_mesVencido],
[doc_documento.alquiler].[observaciones] as [doc_documento.alquiler_observaciones],
		[doc_documento_alquiler].[documento_codigo] AS [doc_documento_alquiler_documento_codigo],
		[doc_documento_alquiler].[documento_numero] AS [doc_documento_alquiler_documento_numero],
		[doc_documento_alquiler].[prefijo] AS [doc_documento_alquiler_prefijo],
		[doc_documento_alquiler].[subtotal] AS [doc_documento_alquiler_subtotal],
		[doc_documento_alquiler].[descuento] AS [doc_documento_alquiler_descuento],
		[doc_documento_alquiler].[iva] AS [doc_documento_alquiler_iva],
		[doc_documento_alquiler].[total] AS [doc_documento_alquiler_total],
		[doc_documento_alquiler].[costo] AS [doc_documento_alquiler_costo],
		[doc_documento_alquiler].[rentabilidad] AS [doc_documento_alquiler_rentabilidad],
		[doc_documento_alquiler].[trm] AS [doc_documento_alquiler_trm],
		[doc_documento_alquiler].[fecha_fh] AS [doc_documento_alquiler_fecha_fh],
		[doc_documento_alquiler].[fechaSugerida_fh] AS [doc_documento_alquiler_fechaSugerida_fh],
		[doc_documento_alquiler].[fechaCierre_ff] AS [doc_documento_alquiler_fechaCierre_ff],
		[doc_documento_alquiler].[fechaLimite_fh] AS [doc_documento_alquiler_fechaLimite_fh],
		[doc_documento_alquiler].[id_subtipoDocumento] AS [doc_documento_alquiler_id_subtipoDocumento],
		[doc_documento_alquiler].[id_tercero_cliente] AS [doc_documento_alquiler_id_tercero_cliente],
		[doc_documento_alquiler].[id_documento] AS [doc_documento_alquiler_id_documento],
		[doc_documento_alquiler].[id_tercero_proveedor] AS [doc_documento_alquiler_id_tercero_proveedor],
		[doc_documento_alquiler].[id_prioridadDocumento] AS [doc_documento_alquiler_id_prioridadDocumento],
		[doc_documento_alquiler].[id_moneda] AS [doc_documento_alquiler_id_moneda],
		[doc_documento_alquiler].[id_estadoTipoDocumento] AS [doc_documento_alquiler_id_estadoTipoDocumento],
		[doc_documento_alquiler].[id_motivoestado] AS [doc_documento_alquiler_id_motivoestado],
		[doc_documento_alquiler].[subtotalPlaneado] AS [doc_documento_alquiler_subtotalPlaneado],
		[doc_documento_alquiler].[descuentoPlaneado] AS [doc_documento_alquiler_descuentoPlaneado],
		[doc_documento_alquiler].[ivaPlaneado] AS [doc_documento_alquiler_ivaPlaneado],
		[doc_documento_alquiler].[totalPlaneado] AS [doc_documento_alquiler_totalPlaneado],
		[doc_documento_alquiler].[costoPlaneado] AS [doc_documento_alquiler_costoPlaneado],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [equ_pagoAlquiler]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[equ_pagoAlquiler].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[equ_pagoAlquiler].[id_usuario_creo]
	INNER JOIN [doc_documento.alquiler] ON [doc_documento.alquiler].id=[equ_pagoAlquiler].[id_documento.alquiler]
	INNER JOIN [doc_documento] aS [doc_documento_alquiler] ON [doc_documento.alquiler].id = [doc_documento_alquiler].id
	INNER JOIN [gen_empresa] AS empresaCodigo ON [equ_pagoAlquiler].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [equ_pagoAlquiler].active=1
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXusuario_modifico]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_usuario_modifico]= @p_id_usuario_modifico)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXusuario_creo]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_usuario_creo]= @p_id_usuario_creo)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXdocumento_alquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXdocumento_alquiler]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXdocumento_alquiler]
	@p_id_documento_alquiler INT
AS
BEGIN
	SELECT * 
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_documento.alquiler]= @p_id_documento_alquiler)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileres]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileres]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileres]
	
	@p_filtro as varchar (8000) = '1=1',
	@p_orden as varchar (8000) = 'id',
	@p_campos as varchar (8000) = '*' AS
BEGIN
exec ('SELECT '+ @p_campos +
' FROM [view_equ_pagoAlquiler]
WHERE (' + @p_filtro + ') ORDER BY ' + @p_orden)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[lis_equ_pagoAlquileres]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_equ_pagoAlquileres]
GO
CREATE PROCEDURE [lis_equ_pagoAlquileres]
	AS
BEGIN
	SELECT id AS id,
[pagoAlquiler] AS [equ_pagoAlquiler]
	FROM [equ_pagoAlquiler]
	WHERE active = 1
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[upd_equ_pagoAlquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_equ_pagoAlquiler]
GO
CREATE PROCEDURE [upd_equ_pagoAlquiler]
	@p_id int = null,
		@p_uid varchar(500) = null,
		@p_eid varchar(50) = null,
		@p_id_usuario_modifico int = null,
		@p_id_usuario_creo int = null,
		@p_fechaCreacion smalldatetime = null,
		@p_pagoAlquiler varchar(300) = null,
		@p_pagoAlquiler_codigo varchar(100) = null,
		@p_valorPorCobrar money = null,
		@p_valorFacturado money = null,
		@p_numeroFactura varchar(100) = null,
		@p_fechaEsperadaPago_ff smalldatetime = null,
		@p_fecha_factura_ff smalldatetime = null,
		@p_id_documento_alquiler int = null
AS
BEGIN
		UPDATE [equ_pagoAlquiler]
		SET	[uid] = isnull(@p_uid,[uid]),
			[eid] = isnull(@p_eid,[eid]),
			[id_usuario_modifico] = isnull(@p_id_usuario_modifico,[id_usuario_modifico]),
			[id_usuario_creo] = isnull(@p_id_usuario_creo,[id_usuario_creo]),
			[fechaModificacion] = GETDATE(),
			[pagoAlquiler] = isnull(@p_pagoAlquiler,[pagoAlquiler]),
			[pagoAlquiler_codigo] = isnull(@p_pagoAlquiler_codigo,[pagoAlquiler_codigo]),
			[valorPorCobrar] = isnull(@p_valorPorCobrar,[valorPorCobrar]),
			[valorFacturado] = isnull(@p_valorFacturado,[valorFacturado]),
			[numeroFactura] = isnull(@p_numeroFactura,[numeroFactura]),
			[fechaEsperadaPago_ff] = isnull(@p_fechaEsperadaPago_ff,[fechaEsperadaPago_ff]),
			[fecha_factura_ff] = isnull(@p_fecha_factura_ff,[fecha_factura_ff]),
			[id_documento.alquiler] = isnull(@p_id_documento_alquiler,[id_documento.alquiler])
		WHERE (id = @p_id)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ins_equ_pagoAlquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_equ_pagoAlquiler]
GO
CREATE PROCEDURE [ins_equ_pagoAlquiler]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_pagoAlquiler varchar(300),
		@p_pagoAlquiler_codigo varchar(100),
		@p_valorPorCobrar money,
		@p_valorFacturado money,
		@p_numeroFactura varchar(100),
		@p_fechaEsperadaPago_ff smalldatetime,
		@p_fecha_factura_ff smalldatetime,
		@p_id_documento_alquiler int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [equ_pagoAlquiler]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[pagoAlquiler],
			[pagoAlquiler_codigo],
			[valorPorCobrar],
			[valorFacturado],
			[numeroFactura],
			[fechaEsperadaPago_ff],
			[fecha_factura_ff],
			[id_documento.alquiler])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_pagoAlquiler,
			@p_pagoAlquiler_codigo,
			@p_valorPorCobrar,
			@p_valorFacturado,
			@p_numeroFactura,
			@p_fechaEsperadaPago_ff,
			@p_fecha_factura_ff,
			@p_id_documento_alquiler)
		SET @v_id = scope_identity()
UPDATE [equ_pagoAlquiler] set [uid] = [uid] + '_' + convert(varchar(20),@v_id) where [id]=@v_id
SELECT @v_id as id
RETURN @v_id
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[act_equ_pagoAlquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_equ_pagoAlquiler]
GO
CREATE PROCEDURE [act_equ_pagoAlquiler]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [equ_pagoAlquiler]
	SET active=@p_active,
	[id_usuario_modifico] = isnull(@p_id_usuario_modifico,[id_usuario_modifico]),
	[fechaModificacion] = GETDATE()
	WHERE	(id = @p_id)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_equ_pagoAlquiler_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_equ_pagoAlquiler_m]
GO
CREATE PROCEDURE [reg_equ_pagoAlquiler_m]
	@p_id INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT 	[id] AS [id],
		[uid] AS [uid],
		[eid] AS [eid],
		[id_usuario_modifico] AS [id_usuario_modifico],
		[id_usuario_creo] AS [id_usuario_creo],
		[fechaModificacion] AS [fechaModificacion],
		[fechaCreacion] AS [fechaCreacion],
		[active] AS [active],
		[pagoAlquiler] AS [pagoAlquiler],
		[pagoAlquiler_codigo] AS [pagoAlquiler_codigo],
		[valorPorCobrar] AS [valorPorCobrar],
		[valorFacturado] AS [valorFacturado],
		[numeroFactura] AS [numeroFactura],
		[fechaEsperadaPago_ff] AS [fechaEsperadaPago_ff],
		[fecha_factura_ff] AS [fecha_factura_ff],
		[id_documento.alquiler] AS [id_documento.alquiler]
	FROM [equ_pagoAlquiler]
	WHERE	(id = @p_id)
	AND	(eid LIKE @p_eid+'%')

END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_usuario_modifico]= @p_id_usuario_modifico)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXusuario_creo_m]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_usuario_creo]= @p_id_usuario_creo)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileresXdocumento_alquiler_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileresXdocumento_alquiler_m]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileresXdocumento_alquiler_m]
	@p_id_documento_alquiler INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_equ_pagoAlquiler]
	WHERE ([id_documento.alquiler]= @p_id_documento_alquiler)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_equ_pagoAlquileres_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_equ_pagoAlquileres_m]
GO
CREATE PROCEDURE [sel_equ_pagoAlquileres_m]
	@p_eid as varchar (50)='',
	@p_filtro as varchar (8000) = '1=1',
	@p_orden as varchar (8000) = 'id',
	@p_campos as varchar (8000) = '*' AS
BEGIN
exec ('SELECT '+ @p_campos +
' FROM [view_equ_pagoAlquiler]
WHERE  (eid like '''+@p_eid+'%'+''' ) AND (' + @p_filtro + ') ORDER BY ' + @p_orden)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[lis_equ_pagoAlquileres_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_equ_pagoAlquileres_m]
GO
CREATE PROCEDURE [lis_equ_pagoAlquileres_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[pagoAlquiler] AS [equ_pagoAlquiler]
	FROM [equ_pagoAlquiler]
	WHERE active = 1
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aud_equ_pagoAlquiler]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_equ_pagoAlquiler]
GO
CREATE PROCEDURE [aud_equ_pagoAlquiler]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [equ_pagoAlquiler].id as id_tabla,
	[equ_pagoAlquiler].id_usuario_modifico as id_usuario_modifico,
	[equ_pagoAlquiler].id_usuario_creo as id_usuario_creo,
	[equ_pagoAlquiler].fechaModificacion as fechaModificacion,
	[equ_pagoAlquiler].fechaCreacion as fechaCreacion,
	[equ_pagoAlquiler].active as active,
	[equ_pagoAlquiler].[pagoAlquiler] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [equ_pagoAlquiler]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[equ_pagoAlquiler].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[equ_pagoAlquiler].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'equ_pagoAlquiler'
-----------------------------------22/10/2014 11:56:32 a.m.